Beispiel #1
0
 /**
  * test getList controller action
  */
 public function testGetList()
 {
     //delete old data
     $repositoryData = $this->repository->findBy(array('name' => $this->dummyData["name"]));
     foreach ($repositoryData as $testDummy) {
         $this->manager->remove($testDummy);
     }
     $this->manager->flush();
     $dummy = $this->createDummy();
     /** @var Enlight_Controller_Response_ResponseTestCase */
     $params["node"] = 1;
     $this->Request()->setParams($params);
     $this->dispatch('backend/Category/getList');
     $this->assertTrue($this->View()->success);
     $returnData = $this->View()->data;
     $this->assertNotEmpty($returnData);
     $this->assertGreaterThan(0, $this->View()->total);
     $foundDummy = array();
     foreach ($returnData as $dummyData) {
         if ($dummyData["name"] == $dummy->getName()) {
             $foundDummy = $dummyData;
         }
     }
     $this->assertTrue(!empty($foundDummy));
     $this->manager->remove($dummy);
     $this->manager->flush();
 }
 /**
  * test the feed list
  */
 public function testGetFeeds()
 {
     //delete old data
     $feeds = $this->repository->findBy(array('hash' => '0805bbb935327228edb5374083b81416'));
     foreach ($feeds as $testFeed) {
         $this->manager->remove($testFeed);
     }
     $this->manager->flush();
     $feed = $this->createDummy();
     /** @var Enlight_Controller_Response_ResponseTestCase */
     $this->dispatch('backend/ProductFeed/getFeeds?page=1&start=0&limit=30');
     $this->assertTrue($this->View()->success);
     $returnData = $this->View()->data;
     $this->assertNotEmpty($returnData);
     $this->assertGreaterThan(0, $this->View()->totalCount);
     $foundDummyFeed = array();
     foreach ($returnData as $feedData) {
         if ($feedData["name"] == $feed->getName()) {
             $foundDummyFeed = $feedData;
         }
     }
     $this->assertEquals($feed->getId(), $foundDummyFeed["id"]);
     $this->manager->remove($feed);
     $this->manager->flush();
 }
Beispiel #3
0
 /**
  * Test case
  */
 public function testFormShouldBePersisted()
 {
     $form = new Form();
     $form->fromArray($this->testData);
     $this->em->persist($form);
     $this->em->flush();
     $formId = $form->getId();
     // remove form from entity manager
     $this->em->detach($form);
     unset($form);
     $form = $this->repo->find($formId);
     foreach ($this->testData as $fieldname => $value) {
         $getMethod = 'get' . ucfirst($fieldname);
         $this->assertEquals($form->{$getMethod}(), $value);
     }
 }
Beispiel #4
0
 /**
  * Test case
  */
 public function testShouldBePersisted()
 {
     $snippet = new Snippet();
     $snippet->fromArray($this->testData);
     $this->em->persist($snippet);
     $this->em->flush();
     $snippetId = $snippet->getId();
     // remove from entity manager
     $this->em->detach($snippet);
     unset($snippet);
     $snippet = $this->repo->find($snippetId);
     foreach ($this->testData as $fieldname => $value) {
         $getMethod = 'get' . ucfirst($fieldname);
         $this->assertEquals($snippet->{$getMethod}(), $value);
     }
     $this->assertInstanceOf('\\DateTime', $snippet->getCreated());
     $this->assertInstanceOf('\\DateTime', $snippet->getUpdated());
 }
Beispiel #5
0
 public function testEsdShouldBePersisted()
 {
     $esd = new Esd();
     $articleDetail = Shopware()->Models()->getRepository('Shopware\\Models\\Article\\Detail')->findOneBy(array('active' => true));
     $esd->setArticleDetail($articleDetail);
     $esd->fromArray($this->testData);
     $this->em->persist($esd);
     $this->em->flush();
     $esdId = $esd->getId();
     // remove esd from entity manager
     $this->em->detach($esd);
     unset($esd);
     $esd = $this->repo->find($esdId);
     foreach ($this->testData as $fieldname => $value) {
         $getMethod = 'get' . ucfirst($fieldname);
         $this->assertEquals($esd->{$getMethod}(), $value);
     }
     $this->assertInstanceOf('\\DateTime', $esd->getDate());
 }
Beispiel #6
0
 /**
  * Test saveAction controller action - Update an existing customer
  *
  * @depends testAddCustomerPaymentDataWithDebit
  */
 public function testUpdateCustomerPaymentDataWithSepa($dummyDataId)
 {
     $dummyData = $this->repository->find($dummyDataId);
     $sepa = $this->manager->getRepository('Shopware\\Models\\Payment\\Payment')->findOneBy(array('name' => 'sepa'));
     $debit = $this->manager->getRepository('Shopware\\Models\\Payment\\Payment')->findOneBy(array('name' => 'debit'));
     $this->assertEquals($debit->getId(), $dummyData->getPaymentId());
     $this->assertCount(1, $dummyData->getPaymentData()->toArray());
     $params = array('id' => $dummyData->getId(), 'paymentId' => $sepa->getId(), 'paymentData' => array(array('accountHolder' => '', 'accountNumber' => '', 'bankCode' => '', 'bankName' => 'European bank name', 'bic' => '123bic312', 'iban' => '456iban654', 'useBillingData' => true)));
     $this->Request()->setMethod('POST')->setPost($params);
     $this->dispatch('/backend/Customer/save');
     $jsonBody = $this->View()->getAssign();
     $this->assertTrue($this->View()->success);
     $this->assertEquals($sepa->getId(), $jsonBody['data']['paymentId']);
     $this->manager->refresh($dummyData);
     $this->assertEquals($sepa->getId(), $dummyData->getPaymentId());
     $paymentDataArray = $dummyData->getPaymentData()->toArray();
     $this->assertCount(2, $paymentDataArray);
     // Old debit payment data is still there, it's just not used currently
     /** @var \Shopware\Models\Customer\PaymentData $paymentData */
     $paymentData = array_shift($paymentDataArray);
     $this->assertInstanceOf('\\Shopware\\Models\\Customer\\PaymentData', $paymentData);
     $this->assertEquals('Account Holder Name', $paymentData->getAccountHolder());
     $this->assertEquals('1234567890', $paymentData->getAccountNumber());
     $this->assertEquals('2345678901', $paymentData->getBankCode());
     $this->assertEquals('Bank name', $paymentData->getBankName());
     $this->assertEmpty($paymentData->getBic());
     $this->assertEmpty($paymentData->getIban());
     $this->assertFalse($paymentData->getUseBillingData());
     // New SEPA data
     /** @var \Shopware\Models\Customer\PaymentData $paymentData */
     $paymentData = array_shift($paymentDataArray);
     $this->assertInstanceOf('\\Shopware\\Models\\Customer\\PaymentData', $paymentData);
     $this->assertEmpty($paymentData->getAccountHolder());
     $this->assertEmpty($paymentData->getAccountNumber());
     $this->assertEmpty($paymentData->getBankCode());
     $this->assertEquals('European bank name', $paymentData->getBankName());
     $this->assertEquals('123bic312', $paymentData->getBic());
     $this->assertEquals('456iban654', $paymentData->getIban());
     $this->assertTrue($paymentData->getUseBillingData());
     $this->manager->remove($dummyData);
     $this->manager->flush();
 }
Beispiel #7
0
 /**
  * Testcase
  */
 public function testMailShouldBePersisted()
 {
     $mail = new Mail();
     $mail->fromArray($this->testData);
     $this->em->persist($mail);
     $this->em->flush();
     $mailId = $mail->getId();
     // remove mail from entity manager
     $this->em->detach($mail);
     unset($mail);
     $mail = $this->repo->find($mailId);
     foreach ($this->testData as $fieldname => $value) {
         if (substr($fieldname, 0, 2) == 'is') {
             $getMethod = $fieldname;
         } else {
             $getMethod = 'get' . ucfirst($fieldname);
         }
         $this->assertEquals($mail->{$getMethod}(), $value);
     }
 }
 /**
  * test the voucherCode validation methods with the created voucher
  *
  * @depends testAddVoucher
  */
 public function testValidateVoucherCode()
 {
     $params = array();
     $voucherModel = $this->createDummy(false);
     $voucherData = Shopware()->Models()->toArray($voucherModel);
     $params["value"] = $voucherData["voucherCode"];
     $params["param"] = $voucherData["id"];
     $this->Request()->setParams($params);
     $this->dispatch('backend/voucher/validateVoucherCode');
     $this->assertEquals(1, $this->Response()->getBody());
     $this->Request()->clearParams();
     $this->Response()->clearBody();
     $params["value"] = $voucherData["voucherCode"];
     //test with an unknown voucher id
     $params["param"] = 416531;
     $this->Request()->setParams($params);
     $this->dispatch('backend/voucher/validateVoucherCode');
     $this->assertEmpty($this->Response()->getBody());
     $this->manager->remove($voucherModel);
     $this->manager->flush();
 }
 /**
  * test validateTrackingCode controller action
  *
  * @depends testSavePartner
  * @param $id
  * @return $id | dummy id
  */
 public function testValidateTrackingCode($id)
 {
     $params["value"] = "31337";
     $params["param"] = $id;
     $this->Request()->setParams($params);
     $this->Response()->clearBody();
     $this->dispatch('backend/Partner/validateTrackingCode');
     $body = $this->Response()->getBody();
     $this->assertEquals("1", $body);
     $newDummy = $this->createDummy();
     $this->Response()->clearBody();
     $params["value"] = "31337";
     $params["param"] = $newDummy->getId();
     $this->Request()->setParams($params);
     $this->dispatch('backend/Partner/validateTrackingCode');
     $body = $this->Response()->getBody();
     $this->assertTrue(empty($body));
     //delete the new dummy
     $this->manager->remove($newDummy);
     $this->manager->flush();
     return $id;
 }
Beispiel #10
0
 private function orderIsSaved($order)
 {
     $this->em->persist($order);
     $this->em->flush($order);
 }