public function testEncode_userProjectHasNoUserProfileProperties_noProjectSettings() { $e = new MongoTestEnvironment(); $e->clean(); $userId = $e->createUser("User", "Name", "*****@*****.**"); $user = new UserProfileModel($userId); $user->role = SiteRoles::USER; $project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $projectId = $project->id->asString(); $project->addUser($userId, ProjectRoles::CONTRIBUTOR); $user->addProject($projectId); // user profile has data; but the encode method ignores it because the project has not enabled the 'city' property $projectUserProfile = new SfchecksUserProfile(); $projectUserProfile->city = 'myCity'; $user->projectUserProfiles[$projectId] = $projectUserProfile; $user->write(); $project->write(); $dto = UserProfileDto::encode($userId, $e->website); $this->assertIsA($dto['userProfile'], 'array'); $this->assertEqual($dto['userProfile']['id'], $userId); $this->assertEqual($dto['userProfile']['name'], 'Name'); $this->assertEqual($dto['userProfile']['role'], SiteRoles::USER); $this->assertTrue(array_key_exists('avatar_shape', $dto['userProfile'])); $this->assertTrue(array_key_exists('avatar_color', $dto['userProfile'])); $this->assertFalse(isset($dto['userProfile']['projects'])); $this->assertIsA($dto['projectsSettings'], 'array'); $this->assertEqual(count($dto['projectsSettings']), 0); }
public function testEncode_Project_DtoCorrect() { $e = new LexiconMongoTestEnvironment(); $e->clean(); $userId = $e->createUser("User", "Name", "*****@*****.**"); $user = new UserProfileModel($userId); $user->role = SystemRoles::USER; $project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE); $projectId = $project->id->asString(); $project->addUser($userId, ProjectRoles::CONTRIBUTOR); $user->addProject($projectId); $user->interfaceLanguageCode = 'th'; $user->write(); $project->write(); $dto = LexBaseViewDto::encode($projectId, $userId); // test for a few default values $this->assertEqual($dto['config']['inputSystems']['en']['tag'], 'en'); $this->assertTrue($dto['config']['tasks']['dbe']['visible']); $this->assertEqual($dto['config']['entry']['type'], 'fields', 'dto config is not valid'); $this->assertEqual($dto['config']['entry']['fields']['lexeme']['label'], 'Word'); $this->assertEqual($dto['config']['entry']['fields']['lexeme']['label'], 'Word'); $this->assertEqual($dto['config']['entry']['fields']['senses']['fields']['partOfSpeech']['label'], 'Part of Speech'); $this->assertTrue($dto['config']['roleViews']['contributor']['fields']['lexeme']['show']); $this->assertTrue($dto['config']['roleViews']['contributor']['showTasks']['dbe']); // todo re-enable this after userLanguageCode feature is mature //$this->assertEqual($dto['interfaceConfig']['userLanguageCode'], 'th'); $this->assertEqual($dto['interfaceConfig']['selectLanguages']['options']['en'], 'English'); }