activitypub-php/test/TestUtils/TestField.php

48 lines
1.0 KiB
PHP
Raw Normal View History

<?php
namespace ActivityPub\Test\TestUtils;
use ActivityPub\Entities\ActivityPubObject;
use ActivityPub\Entities\Field;
2019-02-14 03:27:47 +00:00
use DateTime;
/**
* Like a Field, but with fixed timestamps for testing
*/
class TestField extends Field
{
private $fixedTime;
protected function __construct( $time = null )
{
if ( ! $time ) {
$time = TestActivityPubObject::getDefaultTime();
}
parent::__construct( $time );
$this->fixedTime = $time;
}
2019-02-14 03:27:47 +00:00
public function setTargetObject( ActivityPubObject $targetObject, DateTime $time = null )
{
parent::setTargetObject( $targetObject, $time );
$this->lastUpdated = $this->fixedTime;
}
2019-02-14 03:27:47 +00:00
public function setValue( $value, DateTime $time = null )
{
parent::setValue( $value, $time );
$this->lastUpdated = $this->fixedTime;
}
2019-02-14 03:27:47 +00:00
protected function setCreated( DateTime $timestamp )
{
// don't set created
}
2019-02-14 03:27:47 +00:00
protected function setLastupdated( DateTime $timestamp )
{
// don't set lastUpdated
}
}