Esempio n. 1
0
 /**
  * Set up before test
  */
 public function setUp()
 {
     $this->app = $this->getMockForAbstractClass(App::class, [], '', false, false, true, []);
     $this->modulesMock = $this->getMock(\Magelight\Components\Modules::class, [], [], '', false);
     $this->configMock = $this->getMock(\Magelight\Config::class, [], [], '', false);
     $this->routerMock = $this->getMock(\Magelight\Components\Router::class, [], [], '', false);
     $this->sessionMock = $this->getMock(\Magelight\Http\Session::class, [], [], '', false);
     $this->translatorMock = $this->getMock(\Magelight\I18n\Translator::class, [], [], '', false);
     $this->eventManagerMock = $this->getMock(\Magelight\Event\Manager::class, [], [], '', false);
     \Magelight\Components\Modules::forgeMock($this->modulesMock);
     \Magelight\Config::forgeMock($this->configMock);
     \Magelight\Components\Router::forgeMock($this->routerMock);
     \Magelight\Http\Session::forgeMock($this->sessionMock);
     \Magelight\I18n\Translator::forgeMock($this->translatorMock);
     \Magelight\Event\Manager::forgeMock($this->eventManagerMock);
 }
Esempio n. 2
0
 public function testToken()
 {
     $this->controller->init();
     $sessionMock = $this->getMock(\Magelight\Http\Session::class, [], [], '', false);
     \Magelight\Http\Session::forgeMock($sessionMock);
     $sessionMock->expects($this->once())->method('set')->with(\Magelight\Controller::DEFAULT_TOKEN_SESSION_INDEX, $this->matchesRegularExpression('/[\\d]+/i'));
     $this->controller->generateToken();
     $sessionMock->expects($this->any())->method('get')->with(\Magelight\Controller::DEFAULT_TOKEN_SESSION_INDEX, null)->will($this->returnValue(123456789));
     $this->assertTrue($this->controller->checkToken(123456789));
     $this->assertFalse($this->controller->checkToken(987654321));
 }