コード例 #1
0
 /**
  * @magentoDataFixture Mage/Customer/_files/customer.php
  */
 public function testIndexAction()
 {
     $session = new Mage_Customer_Model_Session();
     $session->login('*****@*****.**', 'password');
     $this->dispatch('customer/account/index');
     $this->assertContains('<div class="my-account">', $this->getResponse()->getBody());
 }
コード例 #2
0
ファイル: Invitation.php プロジェクト: HPTTeam/hackathon
 /**
  * Saves new invitation data in DB and returns instance
  *
  * @param Mage_Customer_Model_Session $sessionData
  *
  * @return AW_Points_Model_Invitation
  */
 public function saveNewInvitation($sessionData)
 {
     $this->setData($sessionData->getData());
     $this->addData(array('protection_code' => md5(uniqid(microtime(), true)), 'status' => self::INVITATION_NEW, 'date' => $this->getResource()->formatDate(time())));
     $this->save();
     return $this;
 }
コード例 #3
0
 /**
  * Verify wishlist view action
  *
  * The following is verified:
  * - Mage_Wishlist_Model_Resource_Item_Collection
  * - Mage_Wishlist_Block_Customer_Wishlist
  * - Mage_Wishlist_Block_Customer_Wishlist_Items
  * - Mage_Wishlist_Block_Customer_Wishlist_Item_Column
  * - Mage_Wishlist_Block_Customer_Wishlist_Item_Column_Cart
  * - Mage_Wishlist_Block_Customer_Wishlist_Item_Column_Comment
  * - Mage_Wishlist_Block_Customer_Wishlist_Button
  * - that Mage_Wishlist_Block_Customer_Wishlist_Item_Options doesn't throw a fatal error
  *
  * @magentoDataFixture Mage/Wishlist/_files/wishlist.php
  */
 public function testItemColumnBlock()
 {
     $session = new Mage_Customer_Model_Session();
     $session->login('*****@*****.**', 'password');
     $this->dispatch('wishlist/index/index');
     $body = $this->getResponse()->getBody();
     $this->assertStringMatchesFormat('%A<img src="%Asmall_image.jpg" %A alt="Simple Product"%A/>%A', $body);
     $this->assertStringMatchesFormat('%Afunction addWItemToCart(itemId)%A', $body);
     $this->assertStringMatchesFormat('%Aonclick="addWItemToCart(%d);"%A', $body);
     $this->assertStringMatchesFormat('%A<textarea name="description[%d]"%A', $body);
     $this->assertStringMatchesFormat('%A<button%Aonclick="addAllWItemsToCart()"%A', $body);
 }
コード例 #4
0
 /**
  * Make sure customer is logged in and put it into registry
  */
 public function preDispatch()
 {
     parent::preDispatch();
     if (!$this->getRequest()->isDispatched()) {
         return;
     }
     $this->_session = Mage::getSingleton('customer/session');
     if (!$this->_session->authenticate($this)) {
         $this->setFlag('', 'no-dispatch', true);
     }
     Mage::register('current_customer', $this->_session->getCustomer());
 }
コード例 #5
0
 /**
  * Covers app/code/core/Mage/Checkout/Block/Multishipping/Payment/Info.php
  * and app/code/core/Mage/Checkout/Block/Multishipping/Overview.php
  *
  * @magentoDataFixture Mage/Sales/_files/quote.php
  * @magentoDataFixture Mage/Customer/_files/customer.php
  */
 public function testOverviewAction()
 {
     $quote = new Mage_Sales_Model_Quote();
     $quote->load('test01', 'reserved_order_id');
     Mage::getSingleton('Mage_Checkout_Model_Session')->setQuoteId($quote->getId());
     $session = new Mage_Customer_Model_Session();
     $session->login('*****@*****.**', 'password');
     $this->getRequest()->setPost('payment', array('method' => 'checkmo'));
     $this->dispatch('checkout/multishipping/overview');
     $html = $this->getResponse()->getBody();
     $this->assertContains('<p>' . $quote->getPayment()->getMethodInstance()->getTitle() . '</p>', $html);
     $this->assertContains('<span class="price">$10.00</span>', $html);
 }
コード例 #6
0
 /**
  * @magentoDataFixture Mage/Catalog/_files/product_simple_xss.php
  * @magentoDataFixture Mage/Customer/_files/customer.php
  */
 public function testAddActionProductNameXss()
 {
     $this->dispatch('wishlist/index/add/product/1?nocookie=1');
     $messages = $this->_customerSession->getMessages()->getItems();
     $isProductNamePresent = false;
     foreach ($messages as $message) {
         if (strpos($message->getCode(), '&lt;script&gt;alert(&quot;xss&quot;);&lt;/script&gt;') !== false) {
             $isProductNamePresent = true;
         }
         $this->assertNotContains('<script>alert("xss");</script>', $message->getCode());
     }
     $this->assertTrue($isProductNamePresent, 'Product name was not found in session messages');
 }
コード例 #7
0
 /**
  * Delete action
  */
 public function deleteAction()
 {
     $id = $this->getRequest()->getParam('id');
     if (0 === (int) $id) {
         // No ID
         $this->_session->addError($this->__('Invalid entry ID.'));
         $this->_redirectBack();
         return;
     }
     try {
         /** @var $collection Mage_Oauth_Model_Resource_Token_Collection */
         $collection = Mage::getModel('oauth/token')->getCollection();
         $collection->joinConsumerAsApplication()->addFilterByCustomerId($this->_session->getCustomerId())->addFilterByType(Mage_Oauth_Model_Token::TYPE_ACCESS)->addFilterById($id);
         /** @var $model Mage_Oauth_Model_Token */
         $model = $collection->getFirstItem();
         if ($model->getId()) {
             $name = $model->getName();
             $model->delete();
             $this->_session->addSuccess($this->__('Application "%s" has been deleted.', $name));
         } else {
             $this->_session->addError($this->__('Application not found.'));
         }
     } catch (Mage_Core_Exception $e) {
         $this->_session->addError($e->getMessage());
     } catch (Exception $e) {
         $this->_session->addError($this->__('An error occurred on delete application.'));
         Mage::logException($e);
     }
     $this->_redirectBack();
 }
コード例 #8
0
 /**
  * return the last login time as a DateTime object.
  * return null if the last login time cannot be calculated.
  * @param  Mage_Customer_Model_Session
  * @param  Mage_Log_Model_Visitor
  * @return DateTime
  */
 protected function _getLastLoginTime(Mage_Customer_Model_Session $session, Mage_Log_Model_Visitor $visitorLog = null)
 {
     if ($visitorLog && $session->isLoggedIn()) {
         $lastLogin = date_create_from_format(self::MAGE_DATETIME_FORMAT, $this->_customerLog->load($visitorLog->getId(), 'visitor_id')->getLoginAt());
     }
     return isset($lastLogin) ? $lastLogin : null;
 }
コード例 #9
0
ファイル: Session.php プロジェクト: apiceweb/MageBridgeCore
 public function regenerateSessionId()
 {
     if (Mage::helper('magebridge')->isBridge() == false) {
         return parent::regenerateSessionId();
     }
     return $this;
 }
コード例 #10
0
 /**
  * Instantiate current profile and put it into registry
  *
  * @return Mage_Sales_Model_Recurring_Profile
  * @throws Mage_Core_Exception
  */
 protected function _initProfile()
 {
     /** @var Mage_Sales_Model_Recurring_Profile $profile */
     $profile = Mage::getModel('sales/recurring_profile')->load($this->getRequest()->getParam('profile'));
     if (!$profile->getId() || $this->_session->getCustomerId() != $profile->getCustomerId()) {
         Mage::throwException($this->__('Specified profile does not exist.'));
     }
     Mage::register('current_recurring_profile', $profile);
     return $profile;
 }
コード例 #11
0
 /**
  * Stub out dependencies to get through a very basic completion of an order
  * submit.
  *
  * @return self
  */
 protected function _stubForBasicOrderSubmitCompletion()
 {
     // Stubs to get through submit order. Assertions related to these stubs
     // will be covered in more targeted tests.
     $this->_customerSession->method('isLoggedIn')->will($this->returnValue(false));
     $this->_multishippingFactory->method('createOrderSaveTransaction')->will($this->returnValue($this->_transaction));
     $this->_order->method('addData')->will($this->returnSelf());
     $this->_order->method('collectShipmentAmounts')->will($this->returnSelf());
     $this->_order->method('getItemsCollection')->will($this->returnValue([]));
     $this->_order->method('setId')->will($this->returnSelf());
     $this->_order->method('setPayment')->will($this->returnSelf());
     $this->_order->method('setQuote')->will($this->returnSelf());
     $this->_quote->method('getAllAddresses')->will($this->returnValue([]));
     $this->_quote->method('getCustomer')->will($this->returnValue($this->_customer));
     $this->_quote->method('getPayment')->will($this->returnValue($this->_quotePayment));
     $this->_quoteConvertor->method('paymentToOrderPayment')->will($this->returnValue($this->_orderPayment));
     $this->_quoteConvertor->method('toOrder')->will($this->returnValue($this->_order));
     return $this;
 }
コード例 #12
0
 public function addMessage(Mage_Core_Model_Message_Abstract $message)
 {
     // ensure duplicate messages are not added
     $identifier = md5($message->getType() . '-' . $message->getText() . '-' . $message->getCode() . '-' . $message->getIdentifier() . '-' . (int) $message->getIsSticky());
     $messages = $this->getMessages()->getItems();
     foreach ($messages as $m) {
         $identifier2 = md5($m->getType() . '-' . $m->getText() . '-' . $m->getCode() . '-' . $m->getIdentifier() . '-' . (int) $m->getIsSticky());
         if ($identifier == $identifier2) {
             return $this;
         }
     }
     return parent::addMessage($message);
 }
コード例 #13
0
 /**
  * Customer authorization
  *
  * @param   string $username
  * @param   string $password
  * @return  bool
  *
  * AVECTRA login
  */
 public function login($username, $password)
 {
     if (Mage::getStoreConfig('customer/avectra/login_hook') == 1) {
         return parent::login($username, $password);
     }
     $key = Mage::getModel('icc_avectra/account')->getAvectraKeyByUserPass($username, $password);
     if ($key && $key != '00000000-0000-0000-0000-000000000000') {
         $customer = Mage::getModel('icc_avectra/account')->getUserByAvectraKey($key);
         if ($customer && $customer->getId()) {
             $this->setCustomerAsLoggedIn($customer);
             $this->renewSession();
             $cookie = Mage::getSingleton('core/cookie');
             $cookie->set('Gorilla', $key);
             return true;
         } else {
             $avcustomer = Mage::getModel('icc_avectra/account')->getAvCustomer($key);
             if ($avcustomer) {
                 $customerData = (array) $avcustomer->Individual;
                 if (count($customerData)) {
                     $firstname = isset($customerData['ind_first_name']) ? $customerData['ind_first_name'] : '';
                     $lastname = isset($customerData['ind_last_name']) ? $customerData['ind_last_name'] : '';
                     $filteredData = array('firstname' => $firstname, 'lastname' => $lastname, 'email' => $username, 'password' => $password, 'avectra_key' => $key);
                     $customer = Mage::getModel('customer/customer');
                     $customer->addData($filteredData);
                     $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
                     $customer->setConfirmation(null);
                     try {
                         $customer->save();
                         $this->loginById($customer->getId());
                         $cookie = Mage::getSingleton('core/cookie');
                         $cookie->set('Gorilla', $key);
                         return true;
                     } catch (Exception $e) {
                     }
                 }
             }
         }
     }
     $errorMessage = Mage::getStoreConfig('avectraconnect_options/avectraconfigfields/login_error_message');
     if (empty($errorMessage)) {
         $errorMessage = Mage::helper('customer')->__('Invalid Email or Password.');
     }
     throw Mage::exception('Mage_Core', $errorMessage, Mage_Customer_Model_Customer::EXCEPTION_INVALID_EMAIL_OR_PASSWORD);
 }
コード例 #14
0
 /**
  * Generic profile view action
  */
 protected function _viewAction()
 {
     try {
         $profile = $this->_initProfile();
         $this->_title($this->__('Recurring Profiles'))->_title($this->__('Profile #%s', $profile->getReferenceId()));
         $this->loadLayout();
         $this->_initLayoutMessages('customer/session');
         $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
         if ($navigationBlock) {
             $navigationBlock->setActive('sales/recurring_profile/');
         }
         $this->renderLayout();
         return;
     } catch (Mage_Core_Exception $e) {
         $this->_session->addError($e->getMessage());
     } catch (Exception $e) {
         Mage::logException($e);
     }
     $this->_redirect('*/*/');
 }
コード例 #15
0
ファイル: Compare.php プロジェクト: TomOhme/IP1-Webshop
 /**
  * Calculate cache product compare collection
  *
  * @param  bool $logout
  * @return Mage_Catalog_Helper_Product_Compare
  */
 public function calculate($logout = false)
 {
     // first visit
     if (!$this->_catalogSession->hasCatalogCompareItemsCount() && !$this->_customerId) {
         $count = 0;
     } else {
         /** @var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Compare_Item_Collection */
         $collection = Mage::getResourceModel('catalog/product_compare_item_collection')->useProductItem(true);
         if (!$logout && $this->_customerSession->isLoggedIn()) {
             $collection->setCustomerId($this->_customerSession->getCustomerId());
         } elseif ($this->_customerId) {
             $collection->setCustomerId($this->_customerId);
         } else {
             $collection->setVisitorId($this->_logVisitor->getId());
         }
         /* Price data is added to consider item stock status using price index */
         $collection->addPriceData();
         $this->_productVisibility->addVisibleInSiteFilterToCollection($collection);
         $count = $collection->getSize();
     }
     $this->_catalogSession->setCatalogCompareItemsCount($count);
     return $this;
 }
コード例 #16
0
 private function _viewAction()
 {
     if (!$this->_loadValidSubscription()) {
         return;
     }
     try {
         $subscription = Mage::registry('current_subscription');
         $this->_title(Mage::helper('customweb_subscription')->__('Subscriptions'))->_title(Mage::helper('customweb_subscription')->__('Subscription #%s', $subscription->getReferenceId()));
         $this->loadLayout();
         $this->_initLayoutMessages('customer/session');
         $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
         if ($navigationBlock) {
             $navigationBlock->setActive('customweb_subscription/subscription/');
         }
         $this->renderLayout();
         return;
     } catch (Mage_Core_Exception $e) {
         $this->_session->addError($e->getMessage());
     } catch (Exception $e) {
         Mage::logException($e);
     }
     $this->_redirect('*/*/');
 }
コード例 #17
0
ファイル: Session.php プロジェクト: CE-Webmaster/CE-Hub
 protected function _logout()
 {
     $this->removeSubAccount();
     return parent::_logout();
 }
コード例 #18
0
 /**
  * Determine the path to redirect to based on customer logging status.
  *
  * @param  Mage_Customer_Model_Session
  * @return string
  */
 protected function _getRomReturnPath(Mage_Customer_Model_Session $session)
 {
     return $session->isLoggedIn() ? static::LOGGED_IN_ORDER_HISTORY_PATH : static::GUEST_ORDER_FORM_PATH;
 }
コード例 #19
0
 /**
  * Get restore password params.
  *
  * @param Mage_Customer_Model_Session $session
  * @return array array ($customerId, $resetPasswordToken)
  */
 protected function _getRestorePasswordParameters(Mage_Customer_Model_Session $session)
 {
     return array((int) $session->getData(self::CUSTOMER_ID_SESSION_NAME), (string) $session->getData(self::TOKEN_SESSION_NAME));
 }
コード例 #20
0
ファイル: Observer.php プロジェクト: AndreKlang/Lesti_Fpc
 /**
  * @param Mage_Core_Model_Layout $layout
  * @param Mage_Customer_Model_Session $session
  * @param array $dynamicBlocks
  * @param array $lazyBlocks
  */
 protected function _insertDynamicBlocks(Mage_Core_Model_Layout &$layout, Mage_Customer_Model_Session &$session, array &$dynamicBlocks, array &$lazyBlocks)
 {
     foreach ($dynamicBlocks as $blockName) {
         $block = $layout->getBlock($blockName);
         if ($block) {
             $this->_placeholder[] = Mage::helper('fpc/block')->getPlaceholderHtml($blockName);
             $html = $block->toHtml();
             if (in_array($blockName, $lazyBlocks)) {
                 $session->setData('fpc_lazy_block_' . $blockName, $html);
             }
             $this->_html[] = $html;
         }
     }
 }
コード例 #21
0
ファイル: Observer.php プロジェクト: Eximagen/pfizer
 /**
  * the single login session should always have an active
  * user, the user should match the configuration rules.
  *
  * @param Mage_Customer_Model_Session $customerSession
  * @return boolean
  */
 public function validateAnonymousLoginSession($customerSession)
 {
     /**
      * @var $config Vbw_Punchout_Helper_Config
      * @var $session Vbw_Punchout_Model_Session
      */
     $config = Mage::helper('vbw_punchout/config');
     $groupId = $config->getAnonymousLoginGroup();
     if (!empty($groupId)) {
         if ($customerSession->getCustomerGroupId() != 0) {
             $customer = $customerSession->getCustomer();
             $customer->setGroupId($customerSession->getCustomerGroupId());
             $quote = Mage::getSingleton('checkout/session')->getQuote();
             $quote->setCustomer($customer);
             // $customerSession->setCustomerAsLoggedIn($customer);
         }
     }
 }