Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade PHPUnit to 8.4 min. #143

Merged
merged 7 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ php:
- 7.2
- 7.3
- 7.4
- 8.0

before_install:
- composer self-update
- composer --version
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then wget http://get.sensiolabs.org/php-cs-fixer.phar -O php-cs-fixer.phar; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then wget https://cs.symfony.com/download/php-cs-fixer-v2.phar -O php-cs-fixer.phar; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then php php-cs-fixer.phar --version; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.1.0/php-coveralls.phar; fi

Expand All @@ -19,8 +20,8 @@ install:

script:
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then php php-cs-fixer.phar fix --dry-run -v; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then bin/phpunit --coverage-clover build/logs/clover.xml; fi
- if [ "$TRAVIS_PHP_VERSION" != "7.2" ]; then bin/phpunit; fi
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then vendor/bin/phpunit --coverage-clover build/logs/clover.xml; fi
- if [ "$TRAVIS_PHP_VERSION" != "7.2" ]; then vendor/bin/phpunit; fi

after_script:
- if [ "$TRAVIS_PHP_VERSION" == "7.2" ]; then php php-coveralls.phar -v; fi
15 changes: 8 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
},
"autoload": {
"psr-0": {
"LightSaml\\Tests\\": "tests/",
"LightSaml\\": "src/"
}
},
"autoload-dev": {
"psr-0": {
"LightSaml\\Tests\\": "tests/"
}
},
"require": {
"php": ">=7.2.5",
"php": "^7.2.5|^8.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this change is good. It will prevent the library from being used with PHP 9+.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand what you say because the latest php version is 8.0.2 .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanna exclude php 9+ and it's probably safe to exclude 8.1+, isn't it ?

Copy link
Contributor

Choose a reason for hiding this comment

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

No it's not. Why would you want to artificially exclude future PHP versions? This will make it harder for users to experiment with them and report any bugs. See this thread by a core maintainer of Symfony: https://mobile.twitter.com/nicolasgrekas/status/1263023258938548225

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good to me :)

"robrichards/xmlseclibs": "~2.0|~3.0|~4.0",
"symfony/http-foundation": "~5.0",
"symfony/event-dispatcher": "~5.0"
Expand All @@ -34,16 +38,13 @@
"symfony/dom-crawler": "~5.0",
"symfony/css-selector": "~5.0",
"pimple/pimple": "~3.0",
"phpunit/phpunit": "~5.7|~7",
"monolog/monolog": "~1.3"
"phpunit/phpunit": "^8.4",
"monolog/monolog": "^2.0.0"
},
"suggest": {
"lightsaml/symfony-bridge": "Symfony 2 build container bridge",
"lightsaml/sp-bundle": "Symfony 2 SP security bundle"
},
"config": {
"bin-dir": "bin"
},
"prefer-stable": true,
"minimum-stability": "stable"
}
2 changes: 1 addition & 1 deletion contrib/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if [ ! -f php-cs-fixer.phar ]; then
echo "The php-cs-fixer.phar is required... downloading..."
wget http://get.sensiolabs.org/php-cs-fixer.phar -O php-cs-fixer.phar || curl http://get.sensiolabs.org/php-cs-fixer.phar -o php-cs-fixer.phar || { echo >&2 "I require wget or curl but they are not installed. Aborting."; exit 1; }
wget https://cs.symfony.com/download/php-cs-fixer-v2.phar -O php-cs-fixer.phar || curl https://cs.symfony.com/download/php-cs-fixer-v2.phar -o php-cs-fixer.phar || { echo >&2 "I require wget or curl but they are not installed. Aborting."; exit 1; }
fi

# Copy the pre-commit hook to the current repository hooks directory.
Expand Down
16 changes: 16 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="Test Suite">
<directory>./tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
40 changes: 0 additions & 40 deletions phpunit.xml.dist

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ public function test_do_execute_called_with_assertion_context()
$action->execute($context);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Expected AssertionContext
*/
public function test_throws_context_exception_for_non_assertion_context()
{
$action = $this->getAbstractAssertionActionMock([$this->getLoggerMock()]);
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$this->expectExceptionMessage("Expected AssertionContext");
$action->execute($this->getMockBuilder(ContextInterface::class)->getMock());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ public function test_constructs_with_logger_and_name_id_format()
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Assertion element must have an issuer element
*/
public function test_throws_context_exception_when_assertion_has_no_issuer()
{

$action = new AssertionIssuerFormatValidatorAction(
$loggerMock = $this->getLoggerMock(),
$expectedIssuerFormat = SamlConstants::NAME_ID_FORMAT_EMAIL
Expand All @@ -33,13 +30,12 @@ public function test_throws_context_exception_when_assertion_has_no_issuer()
->method('error')
->with('Assertion element must have an issuer element', $this->isType('array'));

$this->expectExceptionMessage("Assertion element must have an issuer element");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($context);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Response Issuer Format if set must have value 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress' but it was 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'
*/
public function test_throws_context_exception_when_assertion_issuer_format_does_not_matches_expected_format()
{
$action = new AssertionIssuerFormatValidatorAction(
Expand All @@ -57,6 +53,9 @@ public function test_throws_context_exception_when_assertion_issuer_format_does_
$this->isType('array')
);

$this->expectExceptionMessage("Response Issuer Format if set must have value 'urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress' but it was 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ public function test_does_nothing_if_assertion_has_no_subject()
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Unknown InResponseTo '123123123'
*/
public function test_throws_context_exception_on_unknown_in_response_to()
{
$action = new InResponseToValidatorAction(
Expand All @@ -51,6 +47,9 @@ public function test_throws_context_exception_on_unknown_in_response_to()
$subjectConfirmation->setSubjectConfirmationData(new SubjectConfirmationData());
$subjectConfirmation->getSubjectConfirmationData()->setInResponseTo('123123123');

$this->expectExceptionMessage("Unknown InResponseTo '123123123'");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public function test_constructs_with_logger_and_entity_descriptor_store()
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Assertion element must have an issuer element
*/
public function test_throws_context_exception_when_assertion_has_no_issuer()
{
$action = new KnownAssertionIssuerAction(
Expand All @@ -32,15 +28,15 @@ public function test_throws_context_exception_when_assertion_has_no_issuer()
->method('error')
->with('Assertion element must have an issuer element');

$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$this->expectExceptionMessage("Assertion element must have an issuer element");

$action->execute($context);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Unknown issuer 'http://issuer.com'
*/
public function test_throws_context_exception_on_unknown_issuer()
{

$action = new KnownAssertionIssuerAction(
$loggerMock = $this->getLoggerMock(),
$entityDescriptorStoreMock = $this->getEntityDescriptorStoreMock()
Expand All @@ -58,6 +54,9 @@ public function test_throws_context_exception_on_unknown_issuer()
->method('error')
->with("Unknown issuer 'http://issuer.com'");

$this->expectExceptionMessage("Unknown issuer 'http://issuer.com'");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ public function test_does_nothing_when_assertion_has_authn_statement_but_no_bear
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer SubjectConfirmation must contain Recipient attribute
*/
public function test_throws_context_exception_when_bearer_confirmation_has_no_recipient()
{
$action = new RecipientValidatorAction($loggerMock = $this->getLoggerMock(), $this->getEndpointResolverMock());
Expand All @@ -69,15 +65,16 @@ public function test_throws_context_exception_when_bearer_confirmation_has_no_re
->method('error')
->with('Bearer SubjectConfirmation must contain Recipient attribute');

$this->expectExceptionMessage("Bearer SubjectConfirmation must contain Recipient attribute");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Recipient 'http://recipient.com' does not match SP descriptor
*/
public function test_throws_context_exception_when_recipient_does_not_match_any_own_acs_service_location()
{
$this->expectExceptionMessage("Recipient 'http://recipient.com' does not match SP descriptor");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$action = new RecipientValidatorAction(
$loggerMock = $this->getLoggerMock(),
$endpointResolver = $this->getEndpointResolverMock()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ public function test_does_nothing_if_assertion_has_no_bearer_subject()
$this->assertTrue(true);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer Assertion must have ID attribute
*/
public function test_throws_context_exception_when_bearer_assertion_has_no_id()
{
$action = new RepeatedIdValidatorAction(
Expand All @@ -52,13 +48,12 @@ public function test_throws_context_exception_when_bearer_assertion_has_no_id()
->method('error')
->with('Bearer Assertion must have ID attribute', $this->isType('array'));

$this->expectExceptionMessage("Bearer Assertion must have ID attribute");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer Assertion must have Issuer element
*/
public function test_throws_context_exception_when_bearer_assertion_has_no_issuer()
{
$action = new RepeatedIdValidatorAction(
Expand All @@ -77,13 +72,12 @@ public function test_throws_context_exception_when_bearer_assertion_has_no_issue
->method('error')
->with('Bearer Assertion must have Issuer element', $this->isType('array'));

$this->expectExceptionMessage("Bearer Assertion must have Issuer element");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Repeated assertion id '123' of issuer 'http://issuer.com'
*/
public function test_throws_context_exception_for_known_assertion_id()
{
$action = new RepeatedIdValidatorAction(
Expand All @@ -108,15 +102,15 @@ public function test_throws_context_exception_for_known_assertion_id()
->method('error')
->with("Repeated assertion id '123' of issuer 'http://issuer.com'", $this->isType('array'));

$this->expectExceptionMessage("Repeated assertion id '123' of issuer 'http://issuer.com'");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer SubjectConfirmation must have SubjectConfirmationData element
*/
public function test_throws_context_exception_if_no_subject_confirmation_data()
{

$action = new RepeatedIdValidatorAction(
$loggerMock = $this->getLoggerMock(),
$idStoreMock = $this->getIdStoreMock()
Expand All @@ -139,15 +133,16 @@ public function test_throws_context_exception_if_no_subject_confirmation_data()
->method('error')
->with('Bearer SubjectConfirmation must have SubjectConfirmationData element', $this->isType('array'));

$this->expectExceptionMessage("Bearer SubjectConfirmation must have SubjectConfirmationData element");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);

$action->execute($assertionContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Bearer SubjectConfirmation must have NotOnOrAfter attribute
*/
public function test_throws_context_exception_if_no_not_on_or_after_attribute()
{
$this->expectExceptionMessage("Bearer SubjectConfirmation must have NotOnOrAfter attribute");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
$action = new RepeatedIdValidatorAction(
$loggerMock = $this->getLoggerMock(),
$idStoreMock = $this->getIdStoreMock()
Expand Down
2 changes: 1 addition & 1 deletion tests/LightSaml/Tests/Action/CompositeActionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function test_to_string_returns_json_debug_tree_string()
}
EOT;

$this->assertEquals($expectedValue, $actualValue);
$this->assertJsonStringEqualsJsonString($expectedValue, $actualValue);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ public function test_calls_do_execute_with_profile_context()
$action->execute($profileContext);
}

/**
* @expectedException \LightSaml\Error\LightSamlContextException
* @expectedExceptionMessage Expected ProfileContext but got
*/
public function test_throws_exception_on_non_profile_context()
{
$this->expectExceptionMessage("Expected ProfileContext but got");
$this->expectException(\LightSaml\Error\LightSamlContextException::class);
/** @var LoggerInterface|\PHPUnit_Framework_MockObject_MockObject $loggerMock */
$loggerMock = $this->getMockBuilder(LoggerInterface::class)->getMock();
$loggerMock->expects($this->once())
Expand Down