public function testComputedNameFromProfile() { $user = new User(); $user->setFirstname('original'); $this->assertSame('original', $user->getName()); $profile = new Profile(); $user->fromProfile($profile); $this->assertSame('original', $user->getName(), 'nothing should have changed'); $profile->displayName = 'displayName'; $user->fromProfile($profile); $this->assertSame('displayName', $user->getFirstname(), 'displayName should be used as default firstname'); $this->assertSame('displayName', $user->getName(), 'name should be the displayName'); $profile->firstName = 'first'; $user->fromProfile($profile); $this->assertSame('first', $user->getFirstname(), 'firstname should have been copied'); $this->assertSame('first', $user->getName(), 'displayName should be ignored'); $profile->lastName = 'last'; $user->fromProfile($profile); $this->assertSame('last', $user->getLastname(), 'firstname should have been copied'); $this->assertSame('first last', $user->getName(), 'displayName should be ignored'); }