예제 #1
0
 public function testSameValueComparisonSucceeds()
 {
     $attribute = new TimestampAttribute('somedate', $this->getTypeMock());
     $vh1 = $attribute->createValueHolder();
     $vh1->setValue('2015-09-09T22:00:00.000000+00:00');
     $this->assertFalse($vh1->isNull());
     $this->assertFalse($vh1->isDefault());
     $this->assertSame('2015-09-09T22:00:00.000000+00:00', $vh1->getValue()->format('Y-m-d\\TH:i:s.uP'));
     $vh2 = $attribute->createValueHolder();
     $vh2->setValue('2015-09-09T22:00:00.000Z');
     $this->assertFalse($vh2->isNull());
     $this->assertFalse($vh2->isDefault());
     $this->assertSame('2015-09-09T22:00:00.000000+00:00', $vh2->getValue()->format('Y-m-d\\TH:i:s.uP'));
     $this->assertTrue($vh2->sameValueAs($vh1->toNative()), 'Value comparison w/ native value');
     $this->assertTrue($vh2->sameValueAs($vh1->getValue()), 'Value comparison w/ value');
     $this->assertTrue($vh1->sameValueAs($vh2->toNative()), 'Value comparison w/ native value vice versa');
     $this->assertTrue($vh1->sameValueAs($vh2->getValue()), 'Value comparison w/ value vice versa');
 }
예제 #2
0
 public function testMaxConstraint()
 {
     $datetime_max = '2014-12-28T13:45:55.123+01:00';
     $datetime_foo = '2014-12-28T12:45:55.234+00:00';
     $attribute = new TimestampAttribute('publishedAt', $this->getTypeMock(), [TimestampAttribute::OPTION_MAX_TIMESTAMP => $datetime_max]);
     $valueholder = $attribute->createValueHolder();
     $validation_result = $valueholder->setValue($datetime_foo);
     $this->assertTrue($validation_result->getSeverity() >= IncidentInterface::ERROR);
 }