-
Notifications
You must be signed in to change notification settings - Fork 500
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
Tests: introduce namespaces #503
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is a preliminary commit to set up the basics to allow for namespacing the tests. It: * Adds an entry for the namespaced variants of the tests to the PHPUnit config file, so those tests will be found and run. * Adds a custom autoloader for PSR4-based namespaced test classes to the test bootstrap. The old setup is - for now - still left in place to allow for testing each individual step in the transformation. Once the transformation has been completed, the old setup will be removed. **Note**: _the testsuite cannot be named `Requests` as older PHPUnit versions, in that case, would confuse it with the `Requests` class and expect that class to extend the `PHPUnit_Framework_TestCase` class. With that in mind, the testsuite is called `RequestsTests`._
... and add use statements for it and adjust the `extends` in all the test classes which extend from it.
... and add use statements for it and adjust the `extends` in all the test classes which extend from it.
This commit: * Namespaces the class. * Renames the `RequestsTest_ChunkedDecoding` class to `ChunkedDecodingTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file.
This commit: * Namespaces the class. * Renames the `RequestsTest_Cookies` class to `CookiesTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file.
This commit: * Namespaces the class. * Renames the `RequestsTests_Encoding` class to `EncodingTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file.
This commit: * Namespaces the class. * Renames the `RequestsTest_IDNAEncoder` class to `IDNAEncoderTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file.
This commit: * Namespaces the class. * Renames the `RequestsTest_IRI` class to `IRITest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file. * Adjusts the reference to the file in the PHPCS config file.
This commit: * Namespaces the class. * Renames the `RequestsTest_Requests` class to `RequestsTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file.
This commit: * Namespaces the class. * Renames the `RequestsTest_Session` class to `SessionTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file.
This commit: * Namespaces the class. * Renames the `RequestsTest_SSL` class to `SSLTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file.
This commit: * Namespaces the class. * Renames the `RequestsTest_Response_Headers` class to `HeadersTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file.
This commit: * Namespaces the class. * Renames the `RequestsTest_Utility_FilteredIterator` class to `FilteredIteratorTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the named reference to the old test class file from the PHPUnit config file and removes the now empty `testsuite` "General".
This commit: * Namespaces the class. * Renames the `RequestsTest_Auth_Basic` class to `BasicTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the testsuite which previously contained the old test class file from the PHPUnit config file in favour of letting the generic testsuite handle this.
This commit: * Namespaces the class. * Renames the `RequestsTest_Proxy_HTTP` class to `HTTPTest`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Removes the testsuite which previously contained the old test class file from the PHPUnit config file in favour of letting the generic testsuite handle this.
This commit: * Namespaces the classes. * Renames the `RequestsTest_Transport_cURL` class to `CurlTest`. * Renames the `RequestsTest_Transport_fsockopen` class to `FsockopenTest`. * Renames the class files to match the new class names. * Add `use` statements for all used classes. * Removes the testsuite which previously contained the old test class files from the PHPUnit config file in favour of letting the generic testsuite handle this.
This commit: * Namespaces the class. * Renames the `RequestsTest_Mock_Transport` class to `TransportMock`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Adjusts all references to this Mock class in other test files.
This commit: * Namespaces the class. * Renames the `RequestsTest_Mock_Transport` class to `TransportMock`. * Renames the class file to match the new class name. * Add `use` statements for all used classes. * Adjusts all references to this Mock class in other test files.
Now all test classes are namespaced, the old autoloader in the test bootstrap is no longer necessary. Additionally, as long as Composer knows about the namespaced test classes. the (new) custom autoloader is only really needed when PHPUnit is run via a PHAR file. To this end, this commit: * Adds a `autoload-dev` section to the `composer.json` configuration file. * Removes the old autoloader. * And places the "manual" loading of the PHPUnit polyfills autoloader and the custom autoloader in a condition, so they only get used when the tests are run via a PHAR file.
schlessera
approved these changes
Jul 30, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces namespaces to all test related classes. As this commit only affects the tests, this is not a breaking change.
👉🏻 This PR will be easiest to review by checking through the individual commits.
Fixes #459
Related to #460 and partially addressees action point 5 from that issue.
Commit details
Tests: allow for namespacing the tests
This is a preliminary commit to set up the basics to allow for namespacing the tests.
It:
The old setup is - for now - still left in place to allow for testing each individual step in the transformation.
Once the transformation has been completed, the old setup will be removed.
Note: the testsuite cannot be named
Requests
as older PHPUnit versions, in that case, would confuse it with theRequests
class and expect that class to extend thePHPUnit_Framework_TestCase
class. With that in mind, the testsuite is calledRequestsTests
.Tests: namespace the base TestCase class
... and add use statements for it and adjust the
extends
in all the test classes which extend from it.Tests: namespace the Transport base TestCase class
... and add use statements for it and adjust the
extends
in all the test classes which extend from it.Tests: namespace the ChunkedDecoding test class
This commit:
RequestsTest_ChunkedDecoding
class toChunkedDecodingTest
.use
statements for all used classes.Tests: namespace the Cookies test class
This commit:
RequestsTest_Cookies
class toCookiesTest
.use
statements for all used classes.Tests: namespace the Encoding test class
This commit:
RequestsTests_Encoding
class toEncodingTest
.use
statements for all used classes.Tests: namespace the IDNAEncoder test class
This commit:
RequestsTest_IDNAEncoder
class toIDNAEncoderTest
.use
statements for all used classes.Tests: namespace the IRI test class
This commit:
RequestsTest_IRI
class toIRITest
.use
statements for all used classes.Tests: namespace the Requests test class
This commit:
RequestsTest_Requests
class toRequestsTest
.use
statements for all used classes.Tests: namespace the Session test class
This commit:
RequestsTest_Session
class toSessionTest
.use
statements for all used classes.Tests: namespace the SSL test class
This commit:
RequestsTest_SSL
class toSSLTest
.use
statements for all used classes.Tests: namespace the Response_Headers test class
This commit:
RequestsTest_Response_Headers
class toHeadersTest
.use
statements for all used classes.Tests: namespace the Utility_FilteredIterator test class
This commit:
RequestsTest_Utility_FilteredIterator
class toFilteredIteratorTest
.use
statements for all used classes.testsuite
"General".Tests: namespace the Auth_Basic test class
This commit:
RequestsTest_Auth_Basic
class toBasicTest
.use
statements for all used classes.Tests: namespace the Proxy_HTTP test class
This commit:
RequestsTest_Proxy_HTTP
class toHTTPTest
.use
statements for all used classes.Tests: namespace the Transport_* test classes
This commit:
RequestsTest_Transport_cURL
class toCurlTest
.RequestsTest_Transport_fsockopen
class toFsockopenTest
.use
statements for all used classes.Tests: namespace the Transport mock class
This commit:
RequestsTest_Mock_Transport
class toTransportMock
.use
statements for all used classes.Tests: namespace the RawTransport mock class
This commit:
RequestsTest_Mock_Transport
class toTransportMock
.use
statements for all used classes.Tests: finish off namespacing
Now all test classes are namespaced, the old autoloader in the test bootstrap is no longer necessary.
Additionally, as long as Composer knows about the namespaced test classes. the (new) custom autoloader is only really needed when PHPUnit is run via a PHAR file.
To this end, this commit:
autoload-dev
section to thecomposer.json
configuration file.