sameValueAs() public method

Tells whether two DateTimeZone are equal by comparing their names
public sameValueAs ( ValueObjects\ValueObjectInterface $timezone ) : boolean
$timezone ValueObjects\ValueObjectInterface
return boolean
コード例 #1
0
ファイル: TimeZoneTest.php プロジェクト: cermat/valueobjects
 public function testSameValueAs()
 {
     $timeZone1 = new TimeZone(new StringLiteral('Europe/Madrid'));
     $timeZone2 = new TimeZone(new StringLiteral('Europe/Madrid'));
     $timeZone3 = new TimeZone(new StringLiteral('Europe/Berlin'));
     $this->assertTrue($timeZone1->sameValueAs($timeZone2));
     $this->assertFalse($timeZone1->sameValueAs($timeZone3));
     $mock = $this->getMock('ValueObjects\\ValueObjectInterface');
     $this->assertFalse($timeZone1->sameValueAs($mock));
 }
コード例 #2
0
 public function testGetTimeZone()
 {
     $date = new Date(new Year(2013), Month::DECEMBER(), new MonthDay(3));
     $time = new Time(new Hour(20), new Minute(50), new Second(10));
     $dateTime = new DateTime($date, $time);
     $timeZone = new TimeZone(new StringLiteral('Europe/Madrid'));
     $dateTimeWithTz = new DateTimeWithTimeZone($dateTime, $timeZone);
     $this->assertTrue($timeZone->sameValueAs($dateTimeWithTz->getTimeZone()));
 }