Skip to content

Commit 8cf45b1

Browse files
authored
Merge pull request #89 from aik099/risky-test-fix
Solve the risky test warnings in PHPUnit
2 parents f8b1c01 + 20774a2 commit 8cf45b1

12 files changed

+45
-0
lines changed

tests/Hamcrest/AbstractMatcherTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ abstract class AbstractMatcherTest extends TestCase
1212
const ARGUMENT_IGNORED = "ignored";
1313
const ANY_NON_NULL_ARGUMENT = "notnull";
1414

15+
/**
16+
* @before
17+
*/
18+
protected function setUpTest()
19+
{
20+
MatcherAssert::resetCount();
21+
}
22+
1523
abstract protected function createMatcher();
1624

1725
public function assertMatches(\Hamcrest\Matcher $matcher, $arg, $message)
@@ -46,6 +54,9 @@ public function assertMismatchDescription($expected, \Hamcrest\Matcher $matcher,
4654
);
4755
}
4856

57+
/**
58+
* @doesNotPerformAssertions
59+
*/
4960
public function testIsNullSafe()
5061
{
5162
//Should not generate any notices
@@ -56,6 +67,9 @@ public function testIsNullSafe()
5667
);
5768
}
5869

70+
/**
71+
* @doesNotPerformAssertions
72+
*/
5973
public function testCopesWithUnknownTypes()
6074
{
6175
//Should not generate any notices
@@ -65,4 +79,12 @@ public function testCopesWithUnknownTypes()
6579
new NullDescription()
6680
);
6781
}
82+
83+
/**
84+
* @after
85+
*/
86+
protected function tearDownTest()
87+
{
88+
$this->addToAssertionCount(MatcherAssert::getCount());
89+
}
6890
}

tests/Hamcrest/Core/CombinableMatcherTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class CombinableMatcherTest extends \Hamcrest\AbstractMatcherTest
1212
*/
1313
protected function setUpTest()
1414
{
15+
parent::setUpTest();
16+
1517
$this->_either_3_or_4 = \Hamcrest\Core\CombinableMatcher::either(equalTo(3))->orElse(equalTo(4));
1618
$this->_not_3_and_not_4 = \Hamcrest\Core\CombinableMatcher::both(not(equalTo(3)))->andAlso(not(equalTo(4)));
1719
}

tests/Hamcrest/Core/IsInstanceOfTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class IsInstanceOfTest extends \Hamcrest\AbstractMatcherTest
1212
*/
1313
protected function setUpTest()
1414
{
15+
parent::setUpTest();
16+
1517
$this->_baseClassInstance = new \Hamcrest\Core\SampleBaseClass('good');
1618
$this->_subClassInstance = new \Hamcrest\Core\SampleSubClass('good');
1719
}

tests/Hamcrest/Core/SetTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class SetTest extends \Hamcrest\AbstractMatcherTest
1212
*/
1313
protected function setUpTest()
1414
{
15+
parent::setUpTest();
16+
1517
self::$_classProperty = null;
1618
unset($this->_instanceProperty);
1719
}

tests/Hamcrest/FeatureMatcherTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class FeatureMatcherTest extends \Hamcrest\AbstractMatcherTest
3939
*/
4040
protected function setUpTest()
4141
{
42+
parent::setUpTest();
43+
4244
$this->_resultMatcher = $this->_resultMatcher();
4345
}
4446

tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class IsEqualIgnoringWhiteSpaceTest extends \Hamcrest\AbstractMatcherTest
1111
*/
1212
protected function setUpTest()
1313
{
14+
parent::setUpTest();
15+
1416
$this->_matcher = \Hamcrest\Text\IsEqualIgnoringWhiteSpace::equalToIgnoringWhiteSpace(
1517
"Hello World how\n are we? "
1618
);

tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class StringContainsIgnoringCaseTest extends \Hamcrest\AbstractMatcherTest
1313
*/
1414
protected function setUpTest()
1515
{
16+
parent::setUpTest();
17+
1618
$this->_stringContains = \Hamcrest\Text\StringContainsIgnoringCase::containsStringIgnoringCase(
1719
strtolower(self::EXCERPT)
1820
);

tests/Hamcrest/Text/StringContainsInOrderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class StringContainsInOrderTest extends \Hamcrest\AbstractMatcherTest
1111
*/
1212
protected function setUpTest()
1313
{
14+
parent::setUpTest();
15+
1416
$this->_m = \Hamcrest\Text\StringContainsInOrder::stringContainsInOrder(array('a', 'b', 'c'));
1517
}
1618

tests/Hamcrest/Text/StringContainsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class StringContainsTest extends \Hamcrest\AbstractMatcherTest
1313
*/
1414
protected function setUpTest()
1515
{
16+
parent::setUpTest();
17+
1618
$this->_stringContains = \Hamcrest\Text\StringContains::containsString(self::EXCERPT);
1719
}
1820

tests/Hamcrest/Text/StringEndsWithTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class StringEndsWithTest extends \Hamcrest\AbstractMatcherTest
1313
*/
1414
protected function setUpTest()
1515
{
16+
parent::setUpTest();
17+
1618
$this->_stringEndsWith = \Hamcrest\Text\StringEndsWith::endsWith(self::EXCERPT);
1719
}
1820

0 commit comments

Comments
 (0)