コード例 #1
0
 /**
  * @dataProvider provideTokenTypes
  */
 public function testGetToken($tokenType)
 {
     $mockApi = $this->getMockApi();
     $mockApi->expects($this->exactly(2))->method('postRequest')->with($this->isInstanceOf('\\Mediawiki\\Api\\SimpleRequest'))->will($this->returnValue(array('query' => array('tokens' => array($tokenType => 'TKN-' . $tokenType)))));
     $session = new MediawikiSession($mockApi);
     //Although we make 2 calls to the method we assert the tokens method about is only called once
     $this->assertEquals('TKN-' . $tokenType, $session->getToken());
     $this->assertEquals('TKN-' . $tokenType, $session->getToken());
     //Then clearing the tokens and calling again should make a second call!
     $session->clearTokens();
     $this->assertEquals('TKN-' . $tokenType, $session->getToken());
 }
コード例 #2
0
 /**
  * @since 0.1
  * Clears all tokens stored by the api
  */
 public function clearTokens()
 {
     $this->session->clearTokens();
 }