示例#1
0
 /**
  * Saves the registration
  *
  * @return void
  */
 public function saveRegister()
 {
     $paymentData = isset($this->session['sRegister']['payment']['object']) ? $this->session['sRegister']['payment']['object'] : false;
     $this->admin->sSaveRegister();
     $userId = $this->admin->sSYSTEM->_SESSION["sUserId"];
     if (!empty($paymentData) && $userId) {
         $paymentObject = $this->admin->sInitiatePaymentClass($paymentData);
         if ($paymentObject instanceof \ShopwarePlugin\PaymentMethods\Components\BasePaymentMethod) {
             $paymentObject->savePaymentData($userId, $this->request);
         }
     }
 }
示例#2
0
 /**
  * @covers sAdmin::sSaveRegister
  */
 public function testsSaveRegister()
 {
     // Prepare all needed test structures for login
     $testData = array('auth' => array('email' => uniqid() . '*****@*****.**', 'password' => 'fooobar', 'accountmode' => 1, 'encoderName' => 'bcrypt'), 'billing' => array('salutation' => 'testsalutation', 'firstname' => 'testfirstname', 'lastname' => 'testlastname', 'street' => 'teststreet', 'streetnumber' => 'teststreetnumber', 'zipcode' => 'testzipcode', 'city' => 'testcity', 'country' => 'testcountry'), 'payment' => array('object' => array('id' => 2)));
     $this->module->sSYSTEM->sSESSION_ID = uniqid();
     $this->session->offsetSet('sessionId', $this->module->sSYSTEM->sSESSION_ID);
     $this->session->offsetSet('sRegister', $testData);
     // Test that login was successful
     $this->assertEmpty($this->session->offsetGet('sUserId'));
     $this->assertFalse($this->module->sCheckUser());
     $this->assertTrue($this->module->sSaveRegister());
     $userId = $this->session->offsetGet('sUserId');
     $this->assertEquals($userId, Shopware()->Db()->fetchOne('SELECT id FROM s_user WHERE id = ?', array($userId)));
     $this->assertNotEmpty($this->session->offsetGet('sUserId'));
     $this->assertTrue($this->module->sCheckUser());
     // Logout and delete data
     Shopware()->Session()->unsetAll();
     Shopware()->Db()->delete('s_user_attributes', 'userID = ' . $userId);
     Shopware()->Db()->delete('s_user', 'id = ' . $userId);
 }