Skip to content

Commit

Permalink
Added unit test for Twig extension can method
Browse files Browse the repository at this point in the history
  • Loading branch information
yohang committed Apr 30, 2014
1 parent cba2910 commit b74de2e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion tests/Finite/Test/Extension/Twig/FiniteExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ protected function setUp()
'state' => '{{ finite_state(object) }}',
'transitions' => '{% for transition in finite_transitions(object) %}{{ transition }}{% endfor %}',
'properties' => '{% for property, val in finite_properties(object) %}{{ property }}{% endfor %}',
'has' => '{{ finite_has(object, property) ? "yes" : "no" }}'
'has' => '{{ finite_has(object, property) ? "yes" : "no" }}',
'can' => '{{ finite_can(object, transition) ? "yes" : "no" }}'
)
)
);
Expand Down Expand Up @@ -72,6 +73,12 @@ public function testHas()
$this->assertSame('no', $this->env->render('has', array('object' => $this->getObjectMock(), 'property' => 'baz')));
}

public function testCan()
{
$this->assertSame('yes', $this->env->render('can', array('object' => $this->getObjectMock(), 'transition' => 't12')));
$this->assertSame('no', $this->env->render('can', array('object' => $this->getObjectMock(), 'transition' => 't23')));
}

public function getObjectMock()
{
$mock = $this->getMock('Finite\StatefulInterface');
Expand Down

0 comments on commit b74de2e

Please sign in to comment.