Author: Kentaro Ohkouchi
Inheritance: extends Silex\WebTestCase
Ejemplo n.º 1
0
 public function setUp()
 {
     parent::setUp();
     $softDeleteFilter = $this->app['orm.em']->getFilters()->getFilter('soft_delete');
     $softDeleteFilter->setExcludes(array('Eccube\\Entity\\ProductClass'));
     // soft_delete filter を有効にする
     $config = $this->app['orm.em']->getConfiguration();
     $config->addFilter("soft_delete", '\\Eccube\\Doctrine\\Filter\\SoftDeleteFilter');
     $this->app['orm.em']->getFilters()->enable('soft_delete');
     // eccube_install.sh で追加される Member
     $Member = $this->app['eccube.repository.member']->find(2);
     $Product = new Product();
     $ProductClass = new ProductClass();
     $Disp = $this->app['eccube.repository.master.disp']->find(\Eccube\Entity\Master\Disp::DISPLAY_HIDE);
     $ProductType = $this->app['eccube.repository.master.product_type']->find($this->app['config']['product_type_normal']);
     $Product->setName('test')->setCreator($Member)->setDelFlg(Constant::DISABLED)->addProductClass($ProductClass)->setStatus($Disp);
     $ProductClass->setPrice02(1000)->setCreator($Member)->setDelFlg(Constant::DISABLED)->setStockUnlimited(true)->setProductType($ProductType)->setProduct($Product);
     $ProductStock = new \Eccube\Entity\ProductStock();
     $ProductStock->setCreator($Member);
     $ProductClass->setProductStock($ProductStock);
     $ProductStock->setProductClass($ProductClass);
     $this->app['orm.em']->persist($Product);
     $this->app['orm.em']->persist($ProductClass);
     $this->app['orm.em']->persist($ProductStock);
     $this->app['orm.em']->flush();
     $this->Product = $Product;
     $this->ProductClass = $ProductClass;
 }
Ejemplo n.º 2
0
 /**
  * @see http://jamesmcfadden.co.uk/database-unit-testing-with-doctrine-2-and-phpunit/
  */
 public function getConnection()
 {
     // 別途 Application を生成しているような箇所があると動作しないので注意
     $app = EccubeTestCase::createApplication();
     // Get an instance of your entity manager
     $entityManager = $app['orm.em'];
     // Retrieve PDO instance
     $pdo = $entityManager->getConnection()->getWrappedConnection();
     // Clear Doctrine to be safe
     $entityManager->clear();
     // Schema Tool to process our entities
     $tool = new \Doctrine\ORM\Tools\SchemaTool($entityManager);
     $classes = $entityManager->getMetaDataFactory()->getAllMetaData();
     // Drop all classes and re-build them for each test case
     $tool->dropSchema($classes);
     $tool->createSchema($classes);
     $config = new Configuration($app['db']);
     $config->setMigrationsNamespace('DoctrineMigrations');
     $migrationDir = __DIR__ . '/../../../src/Eccube/Resource/doctrine/migration';
     $config->setMigrationsDirectory($migrationDir);
     $config->registerMigrationsFromDirectory($migrationDir);
     $migration = new Migration($config);
     $migration->migrate(null, false);
     self::$app = $app;
     // Pass to PHPUnit
     return $this->createDefaultDBConnection($pdo, 'db_name');
 }
Ejemplo n.º 3
0
 public function setUp()
 {
     parent::setUp();
     $this->Customer = $this->createCustomer();
     $this->Order = $this->createOrder($this->Customer);
     $TaxRule = $this->app['eccube.repository.tax_rule']->getByRule();
     $this->rate = $TaxRule->getTaxRate();
 }
 public function setUp()
 {
     parent::setUp();
     $this->removeCustomer();
     $this->Customer = $this->createCustomer('*****@*****.**');
     $this->Customer1 = $this->createCustomer('*****@*****.**');
     $this->Customer2 = $this->createCustomer('*****@*****.**');
     $this->Customer3 = $this->createCustomer('*****@*****.**');
 }
Ejemplo n.º 5
0
 public function setUp()
 {
     parent::setUp();
     $this->createProduct();
     $this->Customer = $this->createCustomer();
     $this->app['orm.em']->persist($this->Customer);
     $this->app['orm.em']->flush();
     $this->Order = $this->createOrder($this->Customer);
 }
 public function setUp()
 {
     parent::setUp();
     $tables = array('dtb_product_image', 'dtb_product_stock', 'dtb_product_class', 'dtb_product_category', 'dtb_product');
     $this->deleteAllRows($tables);
     for ($i = 0; $i < 3; $i++) {
         $this->createProduct('商品-' . $i);
     }
 }
Ejemplo n.º 7
0
 public function tearDown()
 {
     $to = __DIR__ . '/../../../../../app/Plugin/HookPoint';
     // テスト用プラグインを削除.
     $fs = new Filesystem();
     $fs->remove($to);
     parent::tearDown();
     $this->client = null;
 }
Ejemplo n.º 8
0
 public function tearDown()
 {
     /** @var EntityManager $em */
     $em = $this->app['orm.em'];
     $conn = $em->getConnection();
     $conn->rollback();
     $this->dropTable($conn->getWrappedConnection());
     $conn->beginTransaction();
     parent::tearDown();
 }
Ejemplo n.º 9
0
 public function setUp()
 {
     parent::setUp();
     $paths = array();
     $paths[] = $this->app['config']['template_admin_realdir'];
     $paths[] = $this->app['config']['template_realdir'];
     $paths[] = $this->app['config']['template_default_realdir'];
     $this->app['twig.loader']->addLoader(new \Twig_Loader_Filesystem($paths));
     $app['admin'] = true;
     $app['front'] = true;
 }
Ejemplo n.º 10
0
 public function setUp()
 {
     parent::setUp();
     $this->removeClass();
     $this->Member = $this->app['eccube.repository.member']->find(2);
     for ($i = 0; $i < 3; $i++) {
         $ClassName = new ClassName();
         $ClassName->setName('class-' . $i)->setCreator($this->Member)->setDelFlg(0)->setRank($i);
         $this->app['orm.em']->persist($ClassName);
     }
     $this->app['orm.em']->flush();
 }
Ejemplo n.º 11
0
 public function setUp()
 {
     parent::setUp();
     $this->Member = $this->app['eccube.repository.member']->find(2);
     $Work = $this->app['orm.em']->getRepository('Eccube\\Entity\\Master\\Work')->find(\Eccube\Entity\Master\Work::WORK_ACTIVE_ID);
     for ($i = 0; $i < 3; $i++) {
         $Member = new Member();
         $Member->setLoginId('member-' . $i)->setPassword('password')->setSalt($this->app['eccube.repository.member']->createSalt(5))->setRank($i)->setWork($Work)->setDelFlg(Constant::DISABLED);
         $Member->setPassword($this->app['eccube.repository.member']->encryptPassword($Member));
         $this->app['orm.em']->persist($Member);
     }
     $this->app['orm.em']->flush();
 }
Ejemplo n.º 12
0
 public function setUp()
 {
     parent::setUp();
     $this->removeNews();
     $this->Member = $this->app['eccube.repository.member']->find(2);
     $faker = $this->getFaker();
     for ($i = 0; $i < 3; $i++) {
         $News = new News();
         $News->setTitle('news-' . $i)->setComment($faker->text())->setUrl($faker->url)->setCreator($this->Member)->setSelect(1)->setLinkMethod(1)->setDelFlg(0)->setRank($i);
         $this->app['orm.em']->persist($News);
     }
     $this->app['orm.em']->flush();
 }
Ejemplo n.º 13
0
 public function setUp()
 {
     parent::setUp();
     $this->removeBlock();
     $this->DeviceType = $this->app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
     for ($i = 0; $i < 10; $i++) {
         $Block = new Block();
         $Block->setName('block-' . $i)->setFileName('block/block-' . $i)->setLogicFlg(1)->setDeletableFlg(0)->setDeviceType($this->DeviceType);
         $this->app['orm.em']->persist($Block);
         $this->app['orm.em']->flush();
         // ここで flush しないと, MySQL で ID が取得できない
         $this->block_id = $Block->getId();
     }
 }
Ejemplo n.º 14
0
 public function setUp()
 {
     parent::setUp();
     $this->BaseInfo = $this->app['eccube.repository.base_info']->get();
     $this->BaseInfo->setOptionProductTaxRule(0);
     $this->Product = $this->createProduct('生活必需品');
     // 2017-04-01とか指定すると, 2017年以降で結果が変わってしまうので1年後の日付を指定する
     $ApplyDate = new \DateTime('+1 years');
     $this->TaxRule1 = $this->app['eccube.repository.tax_rule']->find(1);
     $this->TaxRule1->setApplyDate(new \DateTime());
     $this->TaxRule2 = $this->createTaxRule(10, $ApplyDate);
     $this->TaxRule3 = $this->createTaxRule(8, $ApplyDate);
     $this->app['orm.em']->flush();
 }
 public function setUp()
 {
     parent::setUp();
     $this->createProduct();
     $this->Customer = $this->createCustomer();
     $this->Customer->setName01('立方体長');
     $Customer2 = $this->createCustomer();
     $Customer2->setName01('立方隊員');
     $this->app['orm.em']->persist($this->Customer);
     $this->app['orm.em']->persist($Customer2);
     $this->app['orm.em']->flush();
     $this->Order = $this->createOrder($this->Customer);
     $this->Order1 = $this->createOrder($this->Customer);
     $this->Order2 = $this->createOrder($Customer2);
 }
 public function setUp()
 {
     parent::setUp();
     $this->createProduct();
     $this->Customer = $this->createCustomer();
     $this->app['orm.em']->persist($this->Customer);
     $this->app['orm.em']->flush();
     $this->Order = $this->createOrder($this->Customer);
     $this->Order1 = $this->createOrder($this->Customer);
     $this->Order2 = $this->createOrder($this->createCustomer('*****@*****.**'));
     // 新規受付にしておく
     $NewStatus = $this->app['eccube.repository.order_status']->find($this->app['config']['order_new']);
     $this->Order1->setOrderStatus($NewStatus)->setOrderDate(new \DateTime());
     $this->Order2->setOrderStatus($NewStatus)->setOrderDate(new \DateTime());
     $this->app['orm.em']->flush();
 }
Ejemplo n.º 17
0
 public function setUp()
 {
     parent::setUp();
     $faker = $this->getFaker();
     $this->Member = $this->app['eccube.repository.member']->find(2);
     $this->Customer = $this->createCustomer();
     $this->Order = $this->createOrder($this->Customer);
     $MailTemplate = new MailTemplate();
     $MailTemplate->setName($faker->word)->setHeader($faker->word)->setFooter($faker->word)->setSubject($faker->word)->setCreator($this->Member)->setDelFlg(Constant::DISABLED);
     $this->app['orm.em']->persist($MailTemplate);
     $this->app['orm.em']->flush();
     for ($i = 0; $i < 3; $i++) {
         $this->MailHistories[$i] = new MailHistory();
         $this->MailHistories[$i]->setMailTemplate($MailTemplate)->setOrder($this->Order)->setSendDate(new \DateTime())->setMailBody($faker->realText())->setCreator($this->Member)->setSubject('subject-' . $i);
         $this->app['orm.em']->persist($this->MailHistories[$i]);
         $this->app['orm.em']->flush();
     }
 }
Ejemplo n.º 18
0
 public function setUp()
 {
     // テスト時に Application やデータベース接続が不要な場合は、この行を削除してください.
     parent::setUp();
     // ダミーデータを生成する Faker
     $faker = $this->getFaker();
     // テスト用のデータを生成する.
     $BaseInfo = new BaseInfo();
     $BaseInfo->setCompanyName('company')->setShopName($faker->company)->setAddr01($faker->address)->setAddr02($faker->secondaryAddress)->setEmail01($faker->email)->setLatitude($faker->latitude)->setLongitude($faker->longitude)->setUpdateDate($faker->dateTime('now'));
     /*
      * ここでは Doctrine ORM を使用しているが、オブジェクトキャッシュ等により、
      * 期待した結果が得られない場合がある.
      * 必要に応じて、Doctrine DBAL や PDO を使用すること.
      */
     $this->app['orm.em']->persist($BaseInfo);
     $this->app['orm.em']->flush();
     $this->id = $BaseInfo->getId();
 }
Ejemplo n.º 19
0
 public function setUp()
 {
     parent::setUp();
     $faker = $this->getFaker();
     $this->Member = $this->app['eccube.repository.member']->find(2);
     $this->Customer = $this->createCustomer();
     $this->Order = $this->createOrder($this->Customer);
     $this->Product = $this->createProduct();
     $ProductClasses = $this->Product->getProductClasses();
     $this->ProductClass = $ProductClasses[0];
     $quantity = 3;
     $TaxRule = $this->app['eccube.repository.tax_rule']->getByRule();
     // デフォルト課税規則
     $OrderDetail = new OrderDetail();
     $OrderDetail->setProduct($this->Product)->setProductClass($this->ProductClass)->setProductName($this->Product->getName())->setProductCode($this->ProductClass->getCode())->setPrice($this->ProductClass->getPrice02())->setQuantity($quantity)->setTaxRule($TaxRule->getCalcRule()->getId())->setTaxRate($TaxRule->getTaxRate());
     $this->app['orm.em']->persist($OrderDetail);
     $OrderDetail->setOrder($this->Order);
     $this->Order->addOrderDetail($OrderDetail);
     // 1個ずつ別のお届け先に届ける
     for ($i = 0; $i < $quantity; $i++) {
         $Shipping = new Shipping();
         $Shipping->copyProperties($this->Customer);
         $Shipping->setName01($faker->lastName)->setName02($faker->firstName)->setKana01('セイ');
         $this->Order->addShipping($Shipping);
         $Shipping->setOrder($this->Order);
         $this->app['orm.em']->persist($Shipping);
         $ShipmentItem = new ShipmentItem();
         $ShipmentItem->setShipping($Shipping)->setOrder($this->Order)->setProductClass($this->ProductClass)->setProduct($this->Product)->setProductName($this->Product->getName())->setProductCode($this->ProductClass->getCode())->setPrice($this->ProductClass->getPrice02())->setQuantity(1);
         $this->app['orm.em']->persist($ShipmentItem);
     }
     $subTotal = 0;
     foreach ($this->Order->getOrderDetails() as $OrderDetail) {
         $subTotal += $OrderDetail->getPriceIncTax() * $OrderDetail->getQuantity();
     }
     $this->Order->setSubTotal($subTotal);
     $this->Order->setTotal($subTotal);
     $this->Order->setPaymentTotal($subTotal);
     $this->app['orm.em']->flush();
 }
Ejemplo n.º 20
0
 public function setUp()
 {
     parent::setUp();
     $this->DeviceType = $this->app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
 }
 /**
  * {@inheritdoc}
  */
 public function createApplication()
 {
     return EccubeTestCase::createApplication();
 }
Ejemplo n.º 22
0
 public function setUp()
 {
     parent::setUp();
     $this->email = '*****@*****.**';
     $this->Customer = $this->createCustomer($this->email);
 }
 public function setUp()
 {
     parent::setUp();
 }
Ejemplo n.º 24
0
 public function setUp()
 {
     parent::setUp();
     $this->OrderStatusRepository = $this->app['orm.em']->getRepository('Eccube\\Entity\\Master\\OrderStatus');
 }
Ejemplo n.º 25
0
 public function tearDown()
 {
     parent::tearDown();
     $this->client = null;
 }
Ejemplo n.º 26
0
 public function tearDown()
 {
     parent::tearDown();
 }
Ejemplo n.º 27
0
 public function setUp()
 {
     parent::setUp();
     $this->remove();
     $this->createCategories();
 }
Ejemplo n.º 28
0
 public function setUp()
 {
     parent::setUp();
     self::$server = static::createClient();
     $this->client = self::$server;
 }
 public function setUp()
 {
     parent::setUp();
     $this->Customer = $this->createCustomer();
 }
Ejemplo n.º 30
0
 public function setUp()
 {
     parent::setUp();
     $this->event = new HookPointEvent($this->app);
     $this->client = $this->createClient();
 }