Skip to content

Instantly share code, notes, and snippets.

@nanasess
Last active November 7, 2016 02:48
Show Gist options
  • Save nanasess/d98a83c65dbdb6319fa8343b849f5107 to your computer and use it in GitHub Desktop.
Save nanasess/d98a83c65dbdb6319fa8343b849f5107 to your computer and use it in GitHub Desktop.
EC-CUBE test data generator patch
--- a/tests/Eccube/Tests/Fixture/GeneratorTest.php
+++ b/tests/Eccube/Tests/Fixture/GeneratorTest.php
@@ -40,6 +40,7 @@ class GeneratorTest extends EccubeTestCase
public function testDeliveryGenerator()
{
+ $this->markTestSkipped();
$Payments = $this->app['eccube.repository.payment']->findAll();
for ($i = 0; $i < $this->numberOfDeliveries; $i++) {
$Delivery = $this->app['eccube.fixture.generator']->createDelivery();
@@ -59,9 +60,10 @@ class GeneratorTest extends EccubeTestCase
}
$this->assertEquals($this->numberOfDeliveries, count($this->Deliveries));
}
-
+
public function testProductGenerator()
{
+ $this->markTestSkipped();
for ($i = 0; $i < $this->numberOfProducts; $i++) {
$this->Products[] = $this->app['eccube.fixture.generator']->createProduct();
}
@@ -69,6 +71,7 @@ class GeneratorTest extends EccubeTestCase
}
public function testCustomerGenerator()
{
+ $this->markTestSkipped();
for ($i = 0; $i < $this->numberOfCustomer; $i++) {
$this->Customers[] = $this->app['eccube.fixture.generator']->createCustomer();
}
@@ -77,18 +80,32 @@ class GeneratorTest extends EccubeTestCase
public function testOrderGenerator()
{
+ $qb = $this->app['orm.em']->createQueryBuilder();
+ $qb->select("count(c.id)")
+ ->from("Eccube\\Entity\\Customer", "c");
+ $query = $qb->getQuery();
+ $count = $query->getSingleScalarResult();
+ if ($count > 100000) {
+ $this->markTestSkipped();
+ }
$faker = $this->getFaker();
- $Customers = $this->app['eccube.repository.customer']->findAll();
+ for ($i = 0; $i < $this->numberOfCustomer; $i++) {
+ $this->Customers[] = $this->app['eccube.fixture.generator']->createCustomer();
+ }
+ for ($i = 0; $i < $this->numberOfProducts; $i++) {
+ $this->Products[] = $this->app['eccube.fixture.generator']->createProduct();
+ }
+ $Customers = $this->Customers;
$Deliveries = $this->app['eccube.repository.delivery']->findAll();
- $Products = $this->app['eccube.repository.product']->findAll();
- $Status = $this->app['eccube.repository.order_status']->find($this->app['config']['order_new']);
+ $Products = $this->Products;
foreach ($Customers as $Customer) {
- $Delivery = $Deliveries[$faker->numberBetween(0, $this->numberOfDeliveries)];
- $Product = $Products[$faker->numberBetween(0, $this->numberOfProducts)];
+ $Delivery = $Deliveries[$faker->numberBetween(0, count($Deliveries) - 1)];
+ $Product = $Products[$faker->numberBetween(0, $this->numberOfProducts - 1)];
$charge = $faker->randomNumber(4);
$discount = $faker->randomNumber(4);
for ($i = 0; $i < $this->numberOfOrder; $i++) {
$Order = $this->app['eccube.fixture.generator']->createOrder($Customer, $Product->getProductClasses()->toArray(), $Delivery, $charge, $discount);
+ $Status = $this->app['eccube.repository.order_status']->find($faker->numberBetween(1, 8));
$Order->setOrderStatus($Status);
$Order->setOrderDate($faker->dateTimeThisYear());
$this->app['orm.em']->flush($Order);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment