public function testEncode_userProjectHasNoUserProfileProperties_noProjectSettings() { $environ = new MongoTestEnvironment(); $environ->clean(); $userId = $environ->createUser("User", "Name", "*****@*****.**"); $user = new UserProfileModel($userId); $user->role = SiteRoles::USER; $project = $environ->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, $environ->website); $this->assertInternalType('array', $dto['userProfile']); $this->assertEquals($userId, $dto['userProfile']['id']); $this->assertEquals('Name', $dto['userProfile']['name']); $this->assertEquals(SiteRoles::USER, $dto['userProfile']['role']); $this->assertArrayHasKey('avatar_shape', $dto['userProfile']); $this->assertArrayHasKey('avatar_color', $dto['userProfile']); $this->assertFalse(isset($dto['userProfile']['projects'])); $this->assertInternalType('array', $dto['projectsSettings']); $this->assertEquals(0, count($dto['projectsSettings'])); }
/** * Read the user profile from $id * * @return UserProfileDto */ public function user_readProfile() { return UserProfileDto::encode($this->userId, $this->website); }