Esempio n. 1
0
 /**
  * @covers sAdmin::sGetPreviousAddresses
  */
 public function testsGetPreviousAddresses()
 {
     $customer = $this->createDummyCustomer();
     $this->session->offsetSet('sUserId', null);
     // Test no user id
     $this->assertFalse($this->module->sGetPreviousAddresses('shipping'));
     $this->session->offsetSet('sUserId', $customer->getId());
     // Test empty argument scenario
     $this->assertFalse($this->module->sGetPreviousAddresses(''));
     // Test fetching for new customer with no order (should return empty)
     $this->assertCount(0, $this->module->sGetPreviousAddresses('shipping'));
     $this->assertCount(0, $this->module->sGetPreviousAddresses('billing'));
     $this->deleteDummyCustomer($customer);
     // Test with existing demo customer data
     $this->session->offsetSet('sUserId', 1);
     $shippingData = $this->module->sGetPreviousAddresses('shipping');
     $billingData = $this->module->sGetPreviousAddresses('billing');
     $this->assertGreaterThan(0, count($shippingData));
     $this->assertGreaterThan(0, count($billingData));
     $shippingDetails = end($shippingData);
     $billingDetails = end($billingData);
     $this->assertArrayHasKey('hash', $shippingDetails);
     $this->assertArrayHasKey('hash', $billingDetails);
     $this->assertEquals($shippingDetails, $this->module->sGetPreviousAddresses('shipping', $shippingDetails['hash']));
     $this->assertEquals($billingDetails, $this->module->sGetPreviousAddresses('billing', $billingDetails['hash']));
     foreach (array($shippingDetails, $billingDetails) as $details) {
         $this->assertInternalType('array', $details);
         $this->assertCount(13, $details);
         $this->assertArrayHasKey('company', $details);
         $this->assertArrayHasKey('department', $details);
         $this->assertArrayHasKey('salutation', $details);
         $this->assertArrayHasKey('firstname', $details);
         $this->assertArrayHasKey('lastname', $details);
         $this->assertArrayHasKey('street', $details);
         $this->assertArrayHasKey('streetnumber', $details);
         $this->assertArrayHasKey('zipcode', $details);
         $this->assertArrayHasKey('city', $details);
         $this->assertArrayHasKey('country', $details);
         $this->assertArrayHasKey('countryID', $details);
         $this->assertArrayHasKey('countryname', $details);
         $this->assertNotEmpty($details['hash']);
         $this->assertEquals('shopware AG', $details['company']);
         $this->assertEquals('', $details['department']);
         $this->assertEquals('mr', $details['salutation']);
         $this->assertEquals('Max', $details['firstname']);
         $this->assertEquals('Mustermann', $details['lastname']);
         $this->assertEquals('Mustermannstraße', $details['street']);
         $this->assertEquals('92', $details['streetnumber']);
         $this->assertEquals('48624', $details['zipcode']);
         $this->assertEquals('Schöppingen', $details['city']);
         $this->assertEquals('2', $details['country']);
         $this->assertEquals('2', $details['countryID']);
         $this->assertEquals('Deutschland', $details['countryname']);
     }
 }
Esempio n. 2
0
 /**
  * Read saved shipping address
  */
 public function selectShippingAction()
 {
     $this->View()->sTarget = $this->Request()->getParam('sTarget', $this->Request()->getControllerName());
     $this->View()->sShippingAddresses = $this->admin->sGetPreviousAddresses('shipping');
     // If using the new template and we get a request to change address from the checkout page
     // we need to use a different template
     if (Shopware()->Shop()->getTemplate()->getVersion() >= 3 && $this->View()->sTarget == 'checkout') {
         $this->Request()->setControllerName('checkout');
         return $this->View()->loadTemplate('frontend/account/select_shipping_checkout.tpl');
     }
 }
Esempio n. 3
0
 /**
  * Read saved shipping address
  */
 public function selectShippingAction()
 {
     $this->View()->sTarget = $this->Request()->getParam('sTarget', $this->Request()->getControllerName());
     $this->View()->sShippingAddresses = $this->admin->sGetPreviousAddresses('shipping');
 }