/** * test the user authentication to TAO and to the API */ public function testAuth() { //is the user in the db $this->assertFalse($this->userService->loginAvailable($this->testUserData[PROPERTY_USER_LOGIN])); if (tao_models_classes_UserService::singleton()->isASessionOpened()) { tao_models_classes_UserService::singleton()->logout(); } //no other user session $this->assertFalse(tao_models_classes_UserService::singleton()->isASessionOpened()); //check user login $this->assertTrue($this->userService->loginUser($this->testUserData[PROPERTY_USER_LOGIN], $this->clearPassword)); //check session $this->assertTrue(tao_models_classes_UserService::singleton()->isASessionOpened()); $currentUser = $this->userService->getCurrentUser(); $this->assertIsA($currentUser, 'core_kernel_classes_Resource'); foreach ($this->testUserData as $prop => $value) { try { $property = new core_kernel_classes_Property($prop); $v = $currentUser->getUniquePropertyValue(new core_kernel_classes_Property($prop)); $v = $v instanceof core_kernel_classes_Resource ? $v->getUri() : $v->literal; $this->assertEquals($value, $v); } catch (common_Exception $ce) { $this->fail($ce); } } }