Skip to content

Commit

Permalink
Tests for timestampable behavior trait.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhuet committed Jan 26, 2013
1 parent 0a7e22d commit 9259c2f
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 3 deletions.
@@ -1,9 +1,9 @@
<?php
namespace Dibber\Document\Traits\Behavior;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM
, Gedmo
, Dibber\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Gedmo;
use Dibber\Document;

trait Timestampable
{
Expand Down
@@ -0,0 +1,10 @@
<?php
namespace Dibber\Document\Traits\Behavior\Asset;
require_once 'module/Dibber/src/Dibber/Document/Traits/Behavior/Timestampable.php';

use Dibber\Document;

class Timestampable
{
use Document\Traits\Behavior\Timestampable;
}
@@ -0,0 +1,42 @@
<?php
namespace Dibber\Tests\Units\Document\Traits\Behavior\Asset;

require_once(__DIR__ . '/../../Test.php');
require_once(__DIR__ . '/Asset/Timestampable.php');

use Dibber\Document;

class Timestampable extends \Dibber\Tests\Units\Document\Test
{
/** @var Document\Traits\Behavior\Asset\Timestampable */
protected $timestampable;

public function beforeTestMethod($method)
{
$this->timestampable = new \mock\Dibber\Document\Traits\Behavior\Asset\Timestampable;
}

public function testSetCreatedAt()
{
$this
->assert('createdAt is set and retreived')
->if($createdAt = new \DateTime(date('Y-m-d')))
->and($this->timestampable->setCreatedAt($createdAt))
->then
->object($this->timestampable->getCreatedAt())
->isIdenticalTo($createdAt)
;
}

public function testSetUpdatedAt()
{
$this
->assert('updatedAt is set and retreived')
->if($updatedAt = new \DateTime(date('Y-m-d')))
->and($this->timestampable->setUpdatedAt($updatedAt))
->then
->object($this->timestampable->getUpdatedAt())
->isEqualTo($updatedAt)
;
}
}

0 comments on commit 9259c2f

Please sign in to comment.