Skip to content

Commit 9c8847b

Browse files
authored
Add missing test for StringDescription:: toString (#90)
* corrected return types in the DocBlocks of the `Description` interface methods * add test for the `StringDescription::toString` method
1 parent 8cf45b1 commit 9c8847b

2 files changed

Lines changed: 11 additions & 5 deletions

File tree

hamcrest/Hamcrest/Description.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface Description
1919
*
2020
* @param string $text
2121
*
22-
* @return \Hamcrest\Description
22+
* @return static
2323
*/
2424
public function appendText($text);
2525

@@ -29,7 +29,7 @@ public function appendText($text);
2929
*
3030
* @param \Hamcrest\SelfDescribing $value
3131
*
32-
* @return \Hamcrest\Description
32+
* @return static
3333
*/
3434
public function appendDescriptionOf(SelfDescribing $value);
3535

@@ -38,7 +38,7 @@ public function appendDescriptionOf(SelfDescribing $value);
3838
*
3939
* @param mixed $value
4040
*
41-
* @return \Hamcrest\Description
41+
* @return static
4242
*/
4343
public function appendValue($value);
4444

@@ -50,7 +50,7 @@ public function appendValue($value);
5050
* @param string $end
5151
* @param array|\IteratorAggregate|\Iterator $values
5252
*
53-
* @return \Hamcrest\Description
53+
* @return static
5454
*/
5555
public function appendValueList($start, $separator, $end, $values);
5656

@@ -64,7 +64,7 @@ public function appendValueList($start, $separator, $end, $values);
6464
* @param array|\\IteratorAggregate|\\Iterator $values
6565
* must be instances of {@link Hamcrest\SelfDescribing}
6666
*
67-
* @return \Hamcrest\Description
67+
* @return static
6868
*/
6969
public function appendList($start, $separator, $end, $values);
7070
}

tests/Hamcrest/StringDescriptionTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,10 @@ public function testSelfDescribingObjectsCanBeAppendedAsIterators()
162162
$this->_description->appendList('@start@', '@sep@ ', '@end@', $items->getIterator());
163163
$this->assertEquals('@start@foo@sep@ bar@end@', (string) $this->_description);
164164
}
165+
166+
public function testToStringAppendsSelfDescribing()
167+
{
168+
$description = $this->_description->toString(new \Hamcrest\SampleSelfDescriber('foo'));
169+
$this->assertEquals('foo', $description);
170+
}
165171
}

0 commit comments

Comments
 (0)