Skip to content

Commit 69e7340

Browse files
authored
Merge pull request #102 from localheinz/fix/risky
Fix: Risky tests
2 parents b6c6124 + ae70ae7 commit 69e7340

File tree

5 files changed

+39
-29
lines changed

5 files changed

+39
-29
lines changed

phpunit.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
33
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
44
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
beStrictAboutChangesToGlobalState="true"
7+
beStrictAboutOutputDuringTests="true"
8+
beStrictAboutResourceUsageDuringSmallTests="true"
9+
beStrictAboutTestsThatDoNotTestAnything="true"
10+
beStrictAboutTodoAnnotatedTests="true"
11+
verbose="true"
512
>
613
<testsuites>
714
<testsuite name="Unit Tests">

tests/FeatureFlagTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ class FeatureFlagTest extends \PHPUnit_Framework_TestCase
142142

143143
public function testDecode()
144144
{
145-
FeatureFlag::decode(\GuzzleHttp\json_decode(FeatureFlagTest::$json1, true));
146-
FeatureFlag::decode(\GuzzleHttp\json_decode(FeatureFlagTest::$json2, true));
145+
$this->assertInstanceOf(FeatureFlag::class, FeatureFlag::decode(\GuzzleHttp\json_decode(FeatureFlagTest::$json1, true)));
146+
$this->assertInstanceOf(FeatureFlag::class, FeatureFlag::decode(\GuzzleHttp\json_decode(FeatureFlagTest::$json2, true)));
147147
}
148148

149149
public function dataDecodeMulti()

tests/LDClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class LDClientTest extends \PHPUnit_Framework_TestCase
1414

1515
public function testDefaultCtor()
1616
{
17-
new LDClient("BOGUS_SDK_KEY");
17+
$this->assertInstanceOf(LDClient::class, new LDClient("BOGUS_SDK_KEY"));
1818
}
1919

2020
public function testToggleDefault()

tests/LDUserTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace LaunchDarkly\Tests;
33

4+
use LaunchDarkly\LDUser;
45
use LaunchDarkly\LDUserBuilder;
56

67
class LDUserTest extends \PHPUnit_Framework_TestCase
@@ -23,7 +24,10 @@ public function testCoerceLDUserKey()
2324
public function testEmptyCustom()
2425
{
2526
$builder = new LDUserBuilder("[email protected]");
27+
2628
$user = $builder->build();
29+
30+
$this->assertInstanceOf(LDUser::class, $user);
2731
}
2832

2933
public function testLDUserSecondary()

tests/SemanticVersionTest.php

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,31 @@ public function testCanParseVersionWithPrereleaseAndBuild()
4747
$this->assertEquals('build2.4', $sv->build);
4848
}
4949

50+
/**
51+
* @expectedException \InvalidArgumentException
52+
* @expectedExceptionMessage not a valid semantic version
53+
*/
5054
public function testLeadingZeroNotAllowedInMajor()
5155
{
52-
try {
53-
SemanticVersion::parse('02.3.4');
54-
$this->assertTrue(false, 'expected exception');
55-
// can't use expectException method because we must support older PHPUnit
56-
} catch (\InvalidArgumentException $e) {
57-
}
56+
SemanticVersion::parse('02.3.4');
5857
}
5958

59+
/**
60+
* @expectedException \InvalidArgumentException
61+
* @expectedExceptionMessage not a valid semantic version
62+
*/
6063
public function testLeadingZeroNotAllowedInMinor()
6164
{
62-
try {
63-
SemanticVersion::parse('2.03.4');
64-
$this->assertTrue(false, 'expected exception');
65-
} catch (\InvalidArgumentException $e) {
66-
}
65+
SemanticVersion::parse('2.03.4');
6766
}
6867

68+
/**
69+
* @expectedException \InvalidArgumentException
70+
* @expectedExceptionMessage not a valid semantic version
71+
*/
6972
public function testLeadingZeroNotAllowedInPatch()
7073
{
71-
try {
72-
SemanticVersion::parse('2.3.04');
73-
$this->assertTrue(false, 'expected exception');
74-
} catch (\InvalidArgumentException $e) {
75-
}
74+
SemanticVersion::parse('2.3.04');
7675
}
7776

7877
public function testZeroByItselfIsAllowed()
@@ -147,22 +146,22 @@ public function testCanParseVersionWithMajorMinorAndBuildOnlyInLooseMode()
147146
$this->assertEquals('build1', $sv->build);
148147
}
149148

149+
/**
150+
* @expectedException \InvalidArgumentException
151+
* @expectedExceptionMessage not a valid semantic version
152+
*/
150153
public function testCannotParseVersionWithMajorOnlyByDefault()
151154
{
152-
try {
153-
SemanticVersion::parse('2');
154-
$this->assertTrue(false, 'expected exception');
155-
} catch (\InvalidArgumentException $e) {
156-
}
155+
SemanticVersion::parse('2');
157156
}
158157

158+
/**
159+
* @expectedException \InvalidArgumentException
160+
* @expectedExceptionMessage not a valid semantic version
161+
*/
159162
public function testCannotParseVersionWithMajorAndMinorOnlyByDefault()
160163
{
161-
try {
162-
SemanticVersion::parse('2.3');
163-
$this->assertTrue(false, 'expected exception');
164-
} catch (\InvalidArgumentException $e) {
165-
}
164+
SemanticVersion::parse('2.3');
166165
}
167166

168167
public function testEqualVersionsHaveEqualPrecedence()

0 commit comments

Comments
 (0)