diff --git a/phpunit.xml b/phpunit.xml index 409eaafd0..06f984f70 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,6 +2,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" bootstrap="vendor/autoload.php" + colors="true" + beStrictAboutChangesToGlobalState="true" + beStrictAboutOutputDuringTests="true" + beStrictAboutResourceUsageDuringSmallTests="true" + beStrictAboutTestsThatDoNotTestAnything="true" + beStrictAboutTodoAnnotatedTests="true" + verbose="true" > diff --git a/tests/FeatureFlagTest.php b/tests/FeatureFlagTest.php index 51f865b08..ac08dfa04 100644 --- a/tests/FeatureFlagTest.php +++ b/tests/FeatureFlagTest.php @@ -142,8 +142,8 @@ class FeatureFlagTest extends \PHPUnit_Framework_TestCase public function testDecode() { - FeatureFlag::decode(\GuzzleHttp\json_decode(FeatureFlagTest::$json1, true)); - FeatureFlag::decode(\GuzzleHttp\json_decode(FeatureFlagTest::$json2, true)); + $this->assertInstanceOf(FeatureFlag::class, FeatureFlag::decode(\GuzzleHttp\json_decode(FeatureFlagTest::$json1, true))); + $this->assertInstanceOf(FeatureFlag::class, FeatureFlag::decode(\GuzzleHttp\json_decode(FeatureFlagTest::$json2, true))); } public function dataDecodeMulti() diff --git a/tests/LDClientTest.php b/tests/LDClientTest.php index 2c938bca3..e02b9c138 100644 --- a/tests/LDClientTest.php +++ b/tests/LDClientTest.php @@ -14,7 +14,7 @@ class LDClientTest extends \PHPUnit_Framework_TestCase public function testDefaultCtor() { - new LDClient("BOGUS_SDK_KEY"); + $this->assertInstanceOf(LDClient::class, new LDClient("BOGUS_SDK_KEY")); } public function testToggleDefault() diff --git a/tests/LDUserTest.php b/tests/LDUserTest.php index 1733db567..104019b0e 100644 --- a/tests/LDUserTest.php +++ b/tests/LDUserTest.php @@ -1,6 +1,7 @@ build(); + + $this->assertInstanceOf(LDUser::class, $user); } public function testLDUserSecondary() diff --git a/tests/SemanticVersionTest.php b/tests/SemanticVersionTest.php index 073169197..5ef68c399 100644 --- a/tests/SemanticVersionTest.php +++ b/tests/SemanticVersionTest.php @@ -47,32 +47,31 @@ public function testCanParseVersionWithPrereleaseAndBuild() $this->assertEquals('build2.4', $sv->build); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage not a valid semantic version + */ public function testLeadingZeroNotAllowedInMajor() { - try { - SemanticVersion::parse('02.3.4'); - $this->assertTrue(false, 'expected exception'); - // can't use expectException method because we must support older PHPUnit - } catch (\InvalidArgumentException $e) { - } + SemanticVersion::parse('02.3.4'); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage not a valid semantic version + */ public function testLeadingZeroNotAllowedInMinor() { - try { - SemanticVersion::parse('2.03.4'); - $this->assertTrue(false, 'expected exception'); - } catch (\InvalidArgumentException $e) { - } + SemanticVersion::parse('2.03.4'); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage not a valid semantic version + */ public function testLeadingZeroNotAllowedInPatch() { - try { - SemanticVersion::parse('2.3.04'); - $this->assertTrue(false, 'expected exception'); - } catch (\InvalidArgumentException $e) { - } + SemanticVersion::parse('2.3.04'); } public function testZeroByItselfIsAllowed() @@ -147,22 +146,22 @@ public function testCanParseVersionWithMajorMinorAndBuildOnlyInLooseMode() $this->assertEquals('build1', $sv->build); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage not a valid semantic version + */ public function testCannotParseVersionWithMajorOnlyByDefault() { - try { - SemanticVersion::parse('2'); - $this->assertTrue(false, 'expected exception'); - } catch (\InvalidArgumentException $e) { - } + SemanticVersion::parse('2'); } + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessage not a valid semantic version + */ public function testCannotParseVersionWithMajorAndMinorOnlyByDefault() { - try { - SemanticVersion::parse('2.3'); - $this->assertTrue(false, 'expected exception'); - } catch (\InvalidArgumentException $e) { - } + SemanticVersion::parse('2.3'); } public function testEqualVersionsHaveEqualPrecedence()