コード例 #1
0
ファイル: PartTest.php プロジェクト: enzyme/name
 public function testPartReturnsCorrectShortDataWhenPeriodDefined()
 {
     $first = 'Mr.';
     $short = 'Mr.';
     $part = new Part($first);
     $this->assertEquals($short, $part->short());
 }
コード例 #2
0
ファイル: SimpleTest.php プロジェクト: enzyme/name
 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());
 }
コード例 #3
0
ファイル: Format.php プロジェクト: enzyme/name
 /**
  * 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() : '';
 }