StrToTimeTest.php in Tamper 8
File
tests/src/Unit/Plugin/Tamper/StrToTimeTest.php
View source
<?php
namespace Drupal\Tests\tamper\Unit\Plugin\Tamper;
use Drupal\tamper\Exception\TamperException;
use Drupal\tamper\Plugin\Tamper\StrToTime;
class StrToTimeTest extends TamperPluginTestBase {
protected function instantiatePlugin() {
return new StrToTime([], 'strtotime', [], $this
->getMockSourceDefinition());
}
public function testStrToTimeFormat() {
$this
->assertEquals(515995200, $this->plugin
->tamper('1986-05-09 04:00:00 GMT'));
$this
->assertEquals(515995200, $this->plugin
->tamper('May 9, 1986 04:00:00 GMT'));
$this
->assertEquals(515995200, $this->plugin
->tamper('Fri, 09 May 1986 04:00:00 GMT'));
}
public function testTamperExceptionWithInvalidInput() {
$this
->expectException(TamperException::class);
$this->plugin
->tamper(new \stdClass());
}
}