public function testPartReturnsCorrectShortDataWhenPeriodDefined() { $first = 'Mr.'; $short = 'Mr.'; $part = new Part($first); $this->assertEquals($short, $part->short()); }
public function testSimpleNameStoresCorrectStringData() { $prefix = new Part('Mr.'); $first = new Part('Hubert'); $middle = new Part('Alfred'); $last = new Part('Cumberdale'); $name = Simple::fromString('Mr. Hubert Alfred Cumberdale'); $this->assertEquals($prefix->long(), $name->getPrefix()->long()); $this->assertEquals($first->long(), $name->getFirst()->long()); $this->assertEquals($middle->long(), $name->getMiddle()->long()); $this->assertEquals($last->long(), $name->getLast()->long()); $name = Simple::fromString('Hubert Alfred Cumberdale'); $this->assertEquals(null, $name->getPrefix()); $this->assertEquals($first->long(), $name->getFirst()->long()); $this->assertEquals($middle->long(), $name->getMiddle()->long()); $this->assertEquals($last->long(), $name->getLast()->long()); $name = Simple::fromString('Hubert Cumberdale'); $this->assertEquals(null, $name->getPrefix()); $this->assertEquals($first->long(), $name->getFirst()->long()); $this->assertEquals(null, $name->getMiddle()); $this->assertEquals($last->long(), $name->getLast()->long()); $name = Simple::fromString('Hubert'); $this->assertEquals(null, $name->getPrefix()); $this->assertEquals($first->long(), $name->getFirst()->long()); $this->assertEquals(null, $name->getMiddle()); $this->assertEquals(null, $name->getLast()); }
/** * Tries to extract the short version of the given name from this part. * * @param Part $part The part to process. * * @return string */ protected function tryGetShortVersion($part) { return $part !== null ? $part->short() : ''; }