comparison vendor/phpspec/prophecy/spec/Prophecy/Argument/Token/ObjectStateTokenSpec.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace spec\Prophecy\Argument\Token;
4
5 use PhpSpec\ObjectBehavior;
6
7 class ObjectStateTokenSpec extends ObjectBehavior
8 {
9 function let()
10 {
11 $this->beConstructedWith('getName', 'stdClass');
12 }
13
14 function it_implements_TokenInterface()
15 {
16 $this->shouldBeAnInstanceOf('Prophecy\Argument\Token\TokenInterface');
17 }
18
19 function it_is_not_last()
20 {
21 $this->shouldNotBeLast();
22 }
23
24 function it_scores_8_if_argument_object_has_specific_method_state(\ReflectionClass $reflection)
25 {
26 $reflection->getName()->willReturn('stdClass');
27
28 $this->scoreArgument($reflection)->shouldReturn(8);
29 }
30
31 function it_scores_8_if_argument_object_has_specific_property_state(\stdClass $class)
32 {
33 $class->getName = 'stdClass';
34
35 $this->scoreArgument($class)->shouldReturn(8);
36 }
37
38 function it_does_not_score_if_argument_method_state_does_not_match()
39 {
40 $value = new ObjectStateTokenFixtureB('ABC');
41 $value2 = new ObjectStateTokenFixtureB('CBA');
42
43 $this->beConstructedWith('getSelf', $value);
44 $this->scoreArgument($value2)->shouldReturn(false);
45 }
46
47 function it_does_not_score_if_argument_property_state_does_not_match(\stdClass $class)
48 {
49 $class->getName = 'SplFileInfo';
50
51 $this->scoreArgument($class)->shouldReturn(false);
52 }
53
54 function it_does_not_score_if_argument_object_does_not_have_method_or_property(ObjectStateTokenFixtureA $class)
55 {
56 $this->scoreArgument($class)->shouldReturn(false);
57 }
58
59 function it_does_not_score_if_argument_is_not_object()
60 {
61 $this->scoreArgument(42)->shouldReturn(false);
62 }
63
64 function it_has_simple_string_representation()
65 {
66 $this->__toString()->shouldReturn('state(getName(), "stdClass")');
67 }
68 }
69
70 class ObjectStateTokenFixtureA
71 {
72 public $errors;
73 }
74
75 class ObjectStateTokenFixtureB extends ObjectStateTokenFixtureA
76 {
77 public $errors;
78 public $value = null;
79
80 public function __construct($value)
81 {
82 $this->value = $value;
83 }
84
85 public function getSelf()
86 {
87 return $this;
88 }
89 }