1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11: namespace expect\matcher;
12:
13: use expect\FailedMessage;
14:
15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28:
29: final class ToEqual implements ReportableMatcher
30: {
31: 32: 33:
34: private $actual;
35:
36: 37: 38:
39: private $expected;
40:
41: 42: 43:
44: public function __construct($expected)
45: {
46: $this->expected = $expected;
47: }
48:
49: 50: 51:
52: public function match($actual)
53: {
54: $this->actual = $actual;
55:
56: return $this->actual === $this->expected;
57: }
58:
59: 60: 61:
62: public function reportFailed(FailedMessage $message)
63: {
64: $message->appendText("Expected ")
65: ->appendValue($this->actual)
66: ->appendText(' to be ')
67: ->appendValue($this->expected)
68: ->appendText("\n\n")
69: ->appendText(' expected: ')
70: ->appendValue($this->expected)
71: ->appendText("\n")
72: ->appendText(' got: ')
73: ->appendValue($this->actual);
74: }
75:
76: 77: 78:
79: public function reportNegativeFailed(FailedMessage $message)
80: {
81: $message->appendText("Expected ")
82: ->appendValue($this->actual)
83: ->appendText(' not to be ')
84: ->appendValue($this->expected)
85: ->appendText("\n\n")
86: ->appendText(' expected not: ')
87: ->appendValue($this->expected)
88: ->appendText("\n")
89: ->appendText(' got: ')
90: ->appendValue($this->actual);
91: }
92: }
93: