Beispiel #1
0
 /**
  * tests removeToken()
  */
 public function testRemoveToken()
 {
     $this->_formHelperToken->addToken('my-dummy-token');
     $this->assertTrue($this->_formHelperToken->hasToken('my-dummy-token'));
     $this->_formHelperToken->removeToken('my-dummy-token');
     $this->assertFalse($this->_formHelperToken->hasToken('my-dummy-token'));
 }
Beispiel #2
0
 /**
  * test dispatchLoopStartup()
  */
 public function testDispatchLoopStartup()
 {
     $formHelperToken = new Idun_Form_Helper_Token(array('tokenKey' => 'testTokenKey'));
     $formTokenHelper = new Idun_Controller_Plugin_FormToken($formHelperToken);
     $request = new Zend_Controller_Request_Http();
     $_SERVER['REQUEST_METHOD'] = 'GET';
     $this->assertSame(null, $formTokenHelper->dispatchLoopStartup($request));
     $formHelperToken->addToken('test-token');
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $request->setPost('testTokenKey', 'test-token');
     $this->assertTrue($formTokenHelper->dispatchLoopStartup($request));
     $this->assertFalse($formHelperToken->hasToken('test-token'));
     $formHelperToken->addToken('test-token');
     $_SERVER['REQUEST_METHOD'] = 'POST';
     $request->setPost('testTokenKey', 'not-existent-token');
     $this->assertFalse($formTokenHelper->dispatchLoopStartup($request));
     $this->assertEquals('GET', $_SERVER['REQUEST_METHOD']);
     $this->assertSame(array(), $request->getPost());
 }