setUp() public method

Applicaiton を生成しトランザクションを開始する.
public setUp ( )
Exemplo 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;
 }
Exemplo n.º 2
0
 public function setUp()
 {
     parent::setUp();
     // mysqlの場合, トランザクション中にcreate tableを行うと暗黙的にcommitされてしまい, テストデータをロールバックできない
     // そのため, create tableを行った後に, 再度トランザクションを開始するようにしている
     /** @var EntityManager $em */
     $em = $this->app['orm.em'];
     $conn = $em->getConnection();
     $conn->rollback();
     $this->dropTable($conn->getWrappedConnection());
     $this->createTable($conn->getWrappedConnection());
     $conn->beginTransaction();
     // テスト用のエンティティを用意
     $config = $em->getConfiguration();
     $driver = $config->newDefaultAnnotationDriver(__DIR__, false);
     $chain = $config->getMetadataDriverImpl();
     $chain->addDriver($driver, __NAMESPACE__);
     // 初期データより大きい値を指定
     $price02 = $this->getFaker()->randomNumber(9);
     for ($i = 0; $i < 30; $i++) {
         $Product = $this->createProduct(null, 3);
         $this->expectedIds[] = $Product->getId();
         $ProductClasses = $Product->getProductClasses();
         foreach ($ProductClasses as $ProductClass) {
             // product.idの昇順になるよう, product_class.price02を設定する
             $ProductClass->setPrice02($price02 - $i);
             $em->flush($ProductClass);
         }
     }
 }
Exemplo 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('*****@*****.**');
 }
Exemplo 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);
     }
 }
Exemplo n.º 7
0
 public function setUp()
 {
     $from = __DIR__ . '/../HookPoint';
     $to = __DIR__ . '/../../../../../app/Plugin/HookPoint';
     // テスト用プラグインを設置.
     $fs = new Filesystem();
     $fs->mirror($from, $to);
     parent::setUp();
     $this->client = $this->createClient();
 }
Exemplo n.º 8
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;
 }
Exemplo n.º 9
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();
 }
Exemplo n.º 10
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();
 }
Exemplo 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();
 }
Exemplo n.º 12
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();
 }
Exemplo 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();
     }
 }
 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();
 }
Exemplo n.º 16
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();
 }
Exemplo 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();
     }
 }
Exemplo n.º 18
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();
 }
Exemplo n.º 19
0
 public function setUp()
 {
     parent::setUp();
     self::$server = static::createClient();
     $this->client = self::$server;
 }
 public function setUp()
 {
     parent::setUp();
 }
Exemplo n.º 21
0
 public function setUp()
 {
     parent::setUp();
     $this->email = '*****@*****.**';
     $this->Customer = $this->createCustomer($this->email);
 }
Exemplo n.º 22
0
 public function setUp()
 {
     parent::setUp();
     $this->client = $this->createClient();
 }
Exemplo n.º 23
0
 public function setUp()
 {
     parent::setUp();
     $this->OrderStatusRepository = $this->app['orm.em']->getRepository('Eccube\\Entity\\Master\\OrderStatus');
 }
Exemplo n.º 24
0
 public function setUp()
 {
     parent::setUp();
     $this->DeviceType = $this->app['eccube.repository.master.device_type']->find(DeviceType::DEVICE_TYPE_PC);
 }
 public function setUp()
 {
     parent::setUp();
     $this->Customer = $this->createCustomer();
 }
Exemplo n.º 26
0
 public function setUp()
 {
     parent::setUp();
     $this->event = new HookPointEvent($this->app);
     $this->client = $this->createClient();
 }
Exemplo n.º 27
0
 public function setUp()
 {
     parent::setUp();
     $this->remove();
     $this->createCategories();
 }