/**
  * Logs in as a customer by customer id and store id
  *
  * @param int             $customerId
  * @param string|int|null $storeId
  *
  * @return EcomDev_PHPUnit_Mock_Proxy
  */
 public function helperCustomerSession($customerId, $storeId = null)
 {
     $customerSessionMock = TestHelper::invoke('mockSession', 'customer/session', array('renewSession'));
     if ($storeId === null) {
         $storeId = TestUtil::app()->getAnyStoreView()->getCode();
     }
     TestUtil::setCurrentStore($storeId);
     $customerSessionMock->loginById($customerId);
     return $customerSessionMock;
 }
 /**
  * Start session as guest.
  *
  * @param string|int|null $storeId
  *
  * @return EcomDev_PHPUnit_Mock_Proxy
  */
 public function helperGuestSession($storeId = null)
 {
     $guestSessionMock = TestHelper::invoke('mockSession', 'core/session', array('renewSession'));
     /** @var Mage_Core_Model_Session $session */
     $session = $guestSessionMock->getMock();
     $_GET[$session->getSessionIdQueryParam()] = $session->getSessionId();
     // some action need that (loginPost, ...)
     if ($storeId === null) {
         $storeId = TestUtil::app()->getAnyStoreView()->getCode();
     }
     TestUtil::setCurrentStore($storeId);
     return $guestSessionMock;
 }
 /**
  * Creates a new instance of user with unique id
  *
  * Used for stubbing admin user roles
  *
  * @param int $entropy
  * @return Mage_Admin_Model_User
  */
 public function createUser($entropy = 3)
 {
     $userId = floor(microtime(true) * pow(10, $entropy) - floor(time() / 100) * 100 * pow(10, $entropy));
     // Fix for EE gws functionality
     $userRole = Mage::getModel('admin/roles');
     $userRole->setGwsIsAll(1);
     $user = EcomDev_PHPUnit_Helper::invoke('mockModel', 'admin/user', array('reload'))->getMockInstance();
     $user->setId($userId);
     EcomDev_Utils_Reflection::setRestrictedPropertyValue($user, '_role', $userRole);
     return $user;
 }
 /**
  * Tests invoking of helper by action
  *
  */
 public function testInvoke()
 {
     $this->invokeStub();
     $this->assertSame('firstName_one', Helper::invoke('firstName', 'one'));
     $this->assertSame('firstName_one_two', Helper::invoke('firstName', 'one', 'two'));
     $this->assertSame('firstName_one_two_three', Helper::invoke('firstName', 'one', 'two', 'three'));
 }