/** * 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(); }
/** * Tear down */ protected function tearDown() { $mail = $this->repo->findOneBy(array('name' => 'Testmail123')); if (!empty($mail)) { $this->em->remove($mail); $this->em->flush(); } parent::tearDown(); }
/** * Tear down */ protected function tearDown() { $esd = $this->repo->findOneBy(array('file' => '../foobar.pdf')); if (!empty($esd)) { $this->em->remove($esd); $this->em->flush(); } parent::tearDown(); }
/** * Tear down */ protected function tearDown() { $snippet = $this->repo->findOneBy(array('namespace' => 'unit/test/snippettestcase')); if (!empty($snippet)) { $this->em->remove($snippet); $this->em->flush(); } parent::tearDown(); }
/** * Tear down */ protected function tearDown() { $voucher = $this->repo->findOneBy(array('description' => 'description')); if (!empty($voucher)) { $this->em->remove($voucher); $this->em->flush(); } parent::tearDown(); }
/** * 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 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(); }
/** * 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; }