public function testUserPass() { $service = $this->getMock('NKService', array('me')); $service->expects($this->any())->method('me')->will($this->returnValue(new NKUser('person.abc'))); $this->object = $this->getMock('NKAuthentication', array('getToken', 'tokenAvailable', 'getService')); $this->object->expects($this->any())->method('tokenAvailable')->will($this->returnValue(true)); $this->object->expects($this->any())->method('getService')->will($this->returnValue($service)); $result = $this->object->user(); $this->assertInstanceOf('NKUser', $result); $this->assertSame('person.abc', $result->id()); }
/** * Konstruktor, powinieneś go wywołać *zanim wyślesz* jakiekolwiek nagłówki. Konstruktor w przypadku braku sesji PHP * uruchomi ją, aby móc zapisać swój stan. Możesz w argumencie konstruktora podać tablicę klucz => wartość z opcjami * konfiguracyjnymi, lub przekazać obiekt NKConfig. Jeśli nie chcesz ustawiać konfiguracji w konstruktorze, możesz * to zrobić z użyciem metody ->setConfig * * <code> * $conf = array('permissions' => array(NKPermissions::BASIC_PROFILE), * 'key' => 'some_key', * 'secret' => 'some_secret'); * $auth = new NKConnect($conf); * </code> * * <code> * $conf = new NKConfig(); * $conf->permissions' = array(NKPermissions::BASIC_PROFILE); * $conf->key = 'some_key'; * $conf->secret = 'some_secret'; * $auth = new NKConnect($conf); * </code> * * @throws NKConnectUnusableException * @param array|NKConfig $config */ public function __construct($config = null) { parent::__construct($config); if (false !== $this->getHttpRequest()->headersSent()) { throw new NKConnectUnusableException("Headers was already sent, you should call handleCallback() before you render *any* HTML or on separate callback page"); } $this->getHttpRequest()->startSessionIfRequired(); }