Skip to content

Commit

Permalink
Separated deprecation test
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyharris committed Mar 20, 2018
1 parent 2a9f691 commit 1649f20
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions tests/TestCase/ORM/Behavior/TimestampBehaviorTest.php
Expand Up @@ -21,6 +21,7 @@
use Cake\ORM\Entity;
use Cake\ORM\Table;
use Cake\TestSuite\TestCase;
use PHPUnit\Framework\Error\Deprecated;

/**
* Behavior test case
Expand Down Expand Up @@ -226,15 +227,7 @@ public function testModifiedMissingColumn()
public function testUseImmutable()
{
$table = $this->getTable();
$this->Behavior = new TimestampBehavior($table, [
'events' => [
'Model.beforeSave' => [
'created' => 'new',
'modified' => 'always',
'timestamp_str' => 'always',
]
],
]);
$this->Behavior = new TimestampBehavior($table);
$entity = new Entity();
$event = new Event('Model.beforeSave');

Expand All @@ -247,8 +240,29 @@ public function testUseImmutable()
$entity->clean();
$this->Behavior->handleEvent($event, $entity);
$this->assertInstanceOf('Cake\I18n\Time', $entity->modified);
}

$entity->clean();
/**
* tests using non-DateTimeType throws deprecation warning
*
* @return void
*/
public function testNonDateTimeTypeDeprecated()
{
$this->expectException(Deprecated::class);
$this->expectExceptionMessage('TimestampBehavior support for column types other than DateTimeType will be removed in 4.0.');

$table = $this->getTable();
$this->Behavior = new TimestampBehavior($table, [
'events' => [
'Model.beforeSave' => [
'timestamp_str' => 'always',
]
],
]);

$entity = new Entity();
$event = new Event('Model.beforeSave');
$this->Behavior->handleEvent($event, $entity);
$this->assertInternalType('string', $entity->timestamp_str);
}
Expand Down

0 comments on commit 1649f20

Please sign in to comment.