Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables color output.

beStrictAboutChangesToGlobalState="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutResourceUsageDuringSmallTests="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This increases the verbosity of the output.

>
<testsuites>
<testsuite name="Unit Tests">
Expand Down
4 changes: 2 additions & 2 deletions tests/FeatureFlagTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/LDClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really sure if this test makes a lot of sense.

}

public function testToggleDefault()
Expand Down
4 changes: 4 additions & 0 deletions tests/LDUserTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace LaunchDarkly\Tests;

use LaunchDarkly\LDUser;
use LaunchDarkly\LDUserBuilder;

class LDUserTest extends \PHPUnit_Framework_TestCase
Expand All @@ -23,7 +24,10 @@ public function testCoerceLDUserKey()
public function testEmptyCustom()
{
$builder = new LDUserBuilder("[email protected]");

$user = $builder->build();

$this->assertInstanceOf(LDUser::class, $user);
}

public function testLDUserSecondary()
Expand Down
51 changes: 25 additions & 26 deletions tests/SemanticVersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In regards to this comment, what is the minimum PHPUnit version for your changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll run our usual suite of tests against all of our supported PHP versions to be sure.

} 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()
Expand Down Expand Up @@ -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()
Expand Down