|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace spec\PHPCR\Shell\Console\Helper; |
| 4 | + |
| 5 | +use PhpSpec\ObjectBehavior; |
| 6 | +use Prophecy\Argument; |
| 7 | +use PHPCR\NodeInterface; |
| 8 | +use PHPCR\NodeType\NodeTypeInterface; |
| 9 | + |
| 10 | +class NodeHelperSpec extends ObjectBehavior |
| 11 | +{ |
| 12 | + function it_is_initializable() |
| 13 | + { |
| 14 | + $this->shouldHaveType('PHPCR\Shell\Console\Helper\NodeHelper'); |
| 15 | + } |
| 16 | + |
| 17 | + function it_should_provide_a_method_to_determine_if_a_node_has_a_given_mixin( |
| 18 | + NodeInterface $node, |
| 19 | + NodeTypeInterface $mixin1, |
| 20 | + NodeTypeInterface $mixin2, |
| 21 | + NodeTypeInterface $mixin3 |
| 22 | + ) |
| 23 | + { |
| 24 | + $node->getMixinNodeTypes()->willReturn(array( |
| 25 | + $mixin1, $mixin2, $mixin3 |
| 26 | + )); |
| 27 | + |
| 28 | + $mixin1->getName()->willReturn('mixin1'); |
| 29 | + $mixin2->getName()->willReturn('mixin1'); |
| 30 | + $mixin3->getName()->willReturn('mixin3'); |
| 31 | + |
| 32 | + $this->nodeHasMixinType($node, 'mixin1')->shouldReturn(true); |
| 33 | + $this->nodeHasMixinType($node, 'mixin5')->shouldReturn(false); |
| 34 | + } |
| 35 | + |
| 36 | + function it_should_provide_a_method_to_determine_if_a_node_is_versionable( |
| 37 | + NodeInterface $nodeVersionable, |
| 38 | + NodeInterface $nodeNotVersionable, |
| 39 | + NodeTypeInterface $mixin1, |
| 40 | + NodeTypeInterface $mixin2 |
| 41 | + ) |
| 42 | + { |
| 43 | + $nodeVersionable->getMixinNodeTypes()->willReturn(array( |
| 44 | + $mixin1, $mixin2 |
| 45 | + )); |
| 46 | + $nodeNotVersionable->getMixinNodeTypes()->willReturn(array( |
| 47 | + $mixin2 |
| 48 | + )); |
| 49 | + $nodeNotVersionable->getPath()->willReturn('foobar'); |
| 50 | + $mixin1->getName()->willReturn('mix:versionable'); |
| 51 | + $this->assertNodeIsVersionable($nodeVersionable)->shouldReturn(null);; |
| 52 | + |
| 53 | + try { |
| 54 | + $this->assertNodeIsVersionable($nodeNotVersionable); |
| 55 | + } catch (\OutOfBoundsException $e) { |
| 56 | + } |
| 57 | + } |
| 58 | +} |
0 commit comments