diff --git a/.scrutinizer.yml b/.scrutinizer.yml index dc476e935..c450246b4 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -1,32 +1,17 @@ -build: - nodes: - analysis: - project_setup: - override: true - tests: - override: - - php-scrutinizer-run --enable-security-analysis filter: - paths: - - src/ - excluded_paths: - - tests/ + paths: [src/*] + excluded_paths: [tests/*] checks: php: code_rating: true - duplication: true tools: external_code_coverage: - timeout: 3600 - runs: 2 + timeout: 600 + runs: 3 php_code_coverage: false php_loc: enabled: true - excluded_dirs: - - tests/ - - vendor/ - php_cpd: false - php_sim: + excluded_dirs: [tests, vendor] + php_cpd: enabled: true - filter: - paths: ['src/'] \ No newline at end of file + excluded_dirs: [tests, vendor] \ No newline at end of file diff --git a/tests/Components/DataPathTest.php b/tests/Components/DataPathTest.php index 29f685b62..b9dfe3e71 100644 --- a/tests/Components/DataPathTest.php +++ b/tests/Components/DataPathTest.php @@ -11,7 +11,7 @@ * @group path * @group datapath */ -class DataPathTest extends TestCase +final class DataPathTest extends TestCase { /** * @dataProvider invalidDataUriPath @@ -37,7 +37,7 @@ public function testSetState() { $component = new Path('text/plain;charset=us-ascii,Bonjour%20le%20monde%21'); $generateComponent = eval('return '.var_export($component, true).';'); - $this->assertEquals($component, $generateComponent); + self::assertEquals($component, $generateComponent); } public function invalidDataUriPath() @@ -50,13 +50,13 @@ public function invalidDataUriPath() public function testWithPath() { $uri = new Path('text/plain;charset=us-ascii,Bonjour%20le%20monde%21'); - $this->assertSame($uri, $uri->withContent((string) $uri)); + self::assertSame($uri, $uri->withContent((string) $uri)); } public function testDebugInfo() { $component = new Path('text/plain;charset=us-ascii,Bonjour%20le%20monde%21'); - $this->assertInternalType('array', $component->__debugInfo()); + self::assertInternalType('array', $component->__debugInfo()); } /** @@ -66,7 +66,7 @@ public function testDebugInfo() */ public function testDefaultConstructor($path, $expected) { - $this->assertSame($expected, (string) (new Path($path))); + self::assertSame($expected, (string) (new Path($path))); } public function validPathContent() @@ -96,8 +96,8 @@ public function validPathContent() public function testCreateFromPath($path, $mimetype, $mediatype) { $uri = Path::createFromPath(__DIR__.'/data/'.$path); - $this->assertSame($mimetype, $uri->getMimeType()); - $this->assertSame($mediatype, $uri->getMediaType()); + self::assertSame($mimetype, $uri->getMimeType()); + self::assertSame($mediatype, $uri->getMediaType()); } public function validFilePath() @@ -112,7 +112,7 @@ public function testWithParameters() { $uri = new Path('text/plain;charset=us-ascii,Bonjour%20le%20monde%21'); $newUri = $uri->withParameters('charset=us-ascii'); - $this->assertSame($newUri, $uri); + self::assertSame($newUri, $uri); } public function testWithParametersOnBinaryData() @@ -120,7 +120,7 @@ public function testWithParametersOnBinaryData() $expected = 'charset=binary;foo=bar'; $uri = Path::createFromPath(__DIR__.'/data/red-nose.gif'); $newUri = $uri->withParameters($expected); - $this->assertSame($expected, $newUri->getParameters()); + self::assertSame($expected, $newUri->getParameters()); } /** @@ -155,7 +155,7 @@ public function invalidParametersString() */ public function testToBinary($uri) { - $this->assertTrue($uri->toBinary()->isBinaryData()); + self::assertTrue($uri->toBinary()->isBinaryData()); } /** @@ -164,7 +164,7 @@ public function testToBinary($uri) */ public function testToAscii($uri) { - $this->assertFalse($uri->toAscii()->isBinaryData()); + self::assertFalse($uri->toAscii()->isBinaryData()); } public function fileProvider() @@ -199,9 +199,9 @@ public function testBinarySave() $newFilePath = __DIR__.'/data/temp.gif'; $uri = Path::createFromPath(__DIR__.'/data/red-nose.gif'); $res = $uri->save($newFilePath); - $this->assertInstanceOf(SplFileObject::class, $res); + self::assertInstanceOf(SplFileObject::class, $res); $res = null; - $this->assertSame((string) $uri, (string) Path::createFromPath($newFilePath)); + self::assertSame((string) $uri, (string) Path::createFromPath($newFilePath)); // Ensure file handle of \SplFileObject gets closed. $res = null; @@ -213,10 +213,10 @@ public function testRawSave() $newFilePath = __DIR__.'/data/temp.txt'; $uri = Path::createFromPath(__DIR__.'/data/hello-world.txt'); $res = $uri->save($newFilePath); - $this->assertInstanceOf(SplFileObject::class, $res); - $this->assertSame((string) $uri, (string) Path::createFromPath($newFilePath)); + self::assertInstanceOf(SplFileObject::class, $res); + self::assertSame((string) $uri, (string) Path::createFromPath($newFilePath)); $data = file_get_contents($newFilePath); - $this->assertSame(base64_encode($data), $uri->getData()); + self::assertSame(base64_encode($data), $uri->getData()); // Ensure file handle of \SplFileObject gets closed. $res = null; @@ -225,7 +225,7 @@ public function testRawSave() public function testDataPathConstructor() { - $this->assertSame('text/plain;charset=us-ascii,', (string) new Path()); + self::assertSame('text/plain;charset=us-ascii,', (string) new Path()); } public function testInvalidBase64Encoded() diff --git a/tests/Components/FragmentTest.php b/tests/Components/FragmentTest.php index 5770e1881..55c546b21 100644 --- a/tests/Components/FragmentTest.php +++ b/tests/Components/FragmentTest.php @@ -9,7 +9,7 @@ /** * @group fragment */ -class FragmentTest extends TestCase +final class FragmentTest extends TestCase { /** * @dataProvider getUriComponentProvider @@ -18,7 +18,7 @@ class FragmentTest extends TestCase */ public function testGetUriComponent($str, $encoded) { - $this->assertSame($encoded, (new Fragment($str))->getUriComponent()); + self::assertSame($encoded, (new Fragment($str))->getUriComponent()); } public function getUriComponentProvider() @@ -45,8 +45,8 @@ public function getUriComponentProvider() public function testIsNull() { - $this->assertTrue((new Fragment(null))->isNull()); - $this->assertFalse((new Fragment(''))->isNull()); + self::assertTrue((new Fragment(null))->isNull()); + self::assertFalse((new Fragment(''))->isNull()); } /** @@ -57,7 +57,7 @@ public function testIsNull() */ public function testGetValue($str, $expected, $enc_type) { - $this->assertSame($expected, (new Fragment($str))->getContent($enc_type)); + self::assertSame($expected, (new Fragment($str))->getContent($enc_type)); } public function geValueProvider() @@ -85,7 +85,7 @@ public function geValueProvider() */ public function testGetContent($input, $enc_type, $expected) { - $this->assertSame($expected, (new Fragment($input))->getContent($enc_type)); + self::assertSame($expected, (new Fragment($input))->getContent($enc_type)); } public function getContentProvider() @@ -106,15 +106,15 @@ public function testInvalidEncodingTypeThrowException() public function testDebugInfo() { - $this->assertInternalType('array', (new Fragment('yolo'))->__debugInfo()); + self::assertInternalType('array', (new Fragment('yolo'))->__debugInfo()); } public function testPreserverDelimiter() { $fragment = new Fragment(); $altFragment = $fragment->withContent(null); - $this->assertSame($fragment, $altFragment); - $this->assertNull($altFragment->getContent()); - $this->assertSame('', $altFragment->__toString()); + self::assertSame($fragment, $altFragment); + self::assertNull($altFragment->getContent()); + self::assertSame('', $altFragment->__toString()); } } diff --git a/tests/Components/HierarchicalPathTest.php b/tests/Components/HierarchicalPathTest.php index 70f56990a..14ceb02c5 100644 --- a/tests/Components/HierarchicalPathTest.php +++ b/tests/Components/HierarchicalPathTest.php @@ -12,26 +12,26 @@ * @group path * @group hierarchicalpath */ -class HierarchicalPathTest extends TestCase +final class HierarchicalPathTest extends TestCase { public function testDebugInfo() { $component = new Path('yolo'); - $this->assertInternalType('array', $component->__debugInfo()); + self::assertInternalType('array', $component->__debugInfo()); } public function testSetState() { $component = new Path('yolo'); $generateComponent = eval('return '.var_export($component, true).';'); - $this->assertEquals($component, $generateComponent); + self::assertEquals($component, $generateComponent); } public function testDefined() { $component = new Path('yolo'); - $this->assertFalse($component->isNull()); - $this->assertFalse($component->withContent(null)->isNull()); + self::assertFalse($component->isNull()); + self::assertFalse($component->withContent(null)->isNull()); } /** @@ -42,7 +42,7 @@ public function testDefined() public function testValidPath($raw, $parsed) { $path = new Path($raw); - $this->assertSame($parsed, $path->__toString()); + self::assertSame($parsed, $path->__toString()); } public function validPathProvider() @@ -74,7 +74,7 @@ public function testWithContent() { $path = new Path('/path/to/the/sky'); $alt_path = $path->withContent('/path/to/the/sky'); - $this->assertSame($alt_path, $path); + self::assertSame($alt_path, $path); } /** @@ -85,7 +85,7 @@ public function testWithContent() public function testIsAbsolute($raw, $expected) { $path = new Path($raw); - $this->assertSame($expected, $path->isAbsolute()); + self::assertSame($expected, $path->isAbsolute()); } public function isAbsoluteProvider() @@ -108,7 +108,7 @@ public function isAbsoluteProvider() public function testGetSegment($raw, $key, $value, $default) { $path = new Path($raw); - $this->assertSame($value, $path->getSegment($key, $default)); + self::assertSame($value, $path->getSegment($key, $default)); } public function getSegmentProvider() @@ -130,7 +130,7 @@ public function getSegmentProvider() */ public function testCreateFromSegments($input, $has_front_delimiter, $expected) { - $this->assertSame($expected, (string) Path::createFromSegments($input, $has_front_delimiter)); + self::assertSame($expected, (string) Path::createFromSegments($input, $has_front_delimiter)); } public function createFromSegmentsValid() @@ -179,7 +179,7 @@ public function createFromSegmentsInvalid() */ public function testPrepend($source, $prepend, $res) { - $this->assertSame($res, (string) (new Path($source))->prepend($prepend)); + self::assertSame($res, (string) (new Path($source))->prepend($prepend)); } public function prependData() @@ -200,7 +200,7 @@ public function prependData() */ public function testAppend($source, $append, $res) { - $this->assertSame($res, (string) (new Path($source))->append($append)); + self::assertSame($res, (string) (new Path($source))->append($append)); } public function appendData() @@ -226,7 +226,7 @@ public function appendData() */ public function testWithout($origin, $without, $result) { - $this->assertSame($result, (string) (new Path($origin))->withoutSegments($without)); + self::assertSame($result, (string) (new Path($origin))->withoutSegments($without)); } public function withoutProvider() @@ -259,7 +259,7 @@ public function testReplace($raw, $input, $offset, $expected) { $path = new Path($raw); $newPath = $path->replaceSegment($offset, $input); - $this->assertSame($expected, $newPath->__toString()); + self::assertSame($expected, $newPath->__toString()); } public function replaceValid() @@ -282,11 +282,11 @@ public function replaceValid() public function testKeys() { $path = new Path('/bar/3/troll/3'); - $this->assertCount(4, $path->keys()); - $this->assertCount(0, $path->keys('foo')); - $this->assertSame([0], $path->keys('bar')); - $this->assertCount(2, $path->keys('3')); - $this->assertSame([1, 3], $path->keys('3')); + self::assertCount(4, $path->keys()); + self::assertCount(0, $path->keys('foo')); + self::assertSame([0], $path->keys('bar')); + self::assertCount(2, $path->keys('3')); + self::assertSame([1, 3], $path->keys('3')); } /** @@ -298,8 +298,8 @@ public function testKeys() public function testCountable($input, $getSegments, $nbSegment) { $path = new Path($input); - $this->assertCount($nbSegment, $path); - $this->assertSame($getSegments, $path->getSegments()); + self::assertCount($nbSegment, $path); + self::assertSame($getSegments, $path->getSegments()); } public function arrayProvider() @@ -314,7 +314,7 @@ public function arrayProvider() public function testGetBasemane() { $path = new Path('/path/to/my/file.txt'); - $this->assertSame('file.txt', $path->getBasename()); + self::assertSame('file.txt', $path->getBasename()); } /** @@ -324,7 +324,7 @@ public function testGetBasemane() */ public function testGetDirmane($path, $dirname) { - $this->assertSame($dirname, (new Path($path))->getDirname()); + self::assertSame($dirname, (new Path($path))->getDirname()); } public function dirnameProvider() @@ -344,7 +344,7 @@ public function dirnameProvider() public function testGetBasemaneWithEmptyBasename() { $path = new Path('/path/to/my/'); - $this->assertEmpty($path->getBasename()); + self::assertEmpty($path->getBasename()); } /** @@ -354,7 +354,7 @@ public function testGetBasemaneWithEmptyBasename() */ public function testGetExtension($raw, $parsed) { - $this->assertSame($parsed, (new Path($raw))->getExtension()); + self::assertSame($parsed, (new Path($raw))->getExtension()); } public function extensionProvider() @@ -377,8 +377,8 @@ public function extensionProvider() public function testWithExtension($raw, $raw_ext, $new_path, $parsed_ext) { $newPath = (new Path($raw))->withExtension($raw_ext); - $this->assertSame($new_path, (string) $newPath); - $this->assertSame($parsed_ext, $newPath->getExtension()); + self::assertSame($new_path, (string) $newPath); + self::assertSame($parsed_ext, $newPath->getExtension()); } public function withExtensionProvider() @@ -428,7 +428,7 @@ public function invalidExtension() */ public function testWithExtensionPreserveTypeCode($uri, $extension, $expected) { - $this->assertSame( + self::assertSame( $expected, (string) (new Path($uri))->withExtension($extension) ); @@ -453,7 +453,7 @@ public function withExtensionProvider2() public function testGetExtensionPreserveTypeCode($uri, $extension) { $ftp = new Path($uri); - $this->assertSame($extension, $ftp->getExtension()); + self::assertSame($extension, $ftp->getExtension()); } public function getExtensionProvider() @@ -472,7 +472,7 @@ public function getExtensionProvider() */ public function testGetContent($expected, $path) { - $this->assertSame($expected, (new Path($path))->getContent(Path::RFC3987_ENCODING)); + self::assertSame($expected, (new Path($path))->getContent(Path::RFC3987_ENCODING)); } public function geValueProvider() @@ -493,16 +493,16 @@ public function geValueProvider() public function testContentPreserveEncodedChars() { $path = new Path('/hi%2520'); - $this->assertSame('/hi%2520', (string) $path); + self::assertSame('/hi%2520', (string) $path); $src = new Path('/'); - $this->assertSame('/hi%2520', (string) $src->append((string) $path)); + self::assertSame('/hi%2520', (string) $src->append((string) $path)); } public function testAppendDoestNotValidatedPrematurelyString() { $src = new Path('/'); - $this->assertSame('/hi%11', (string) $src->append('hi%11')); + self::assertSame('/hi%11', (string) $src->append('hi%11')); } /** @@ -514,7 +514,7 @@ public function testAppendDoestNotValidatedPrematurelyString() public function testWithDirname($path, $dirname, $expected) { $path = new Path($path); - $this->assertSame($expected, (string) $path->withDirname($dirname)); + self::assertSame($expected, (string) $path->withDirname($dirname)); } public function getDirnameProvider() @@ -563,7 +563,7 @@ public function getDirnameProvider() public function testWithBasename($path, $basename, $expected) { $path = new Path($path); - $this->assertSame($expected, (string) $path->withBasename($basename)); + self::assertSame($expected, (string) $path->withBasename($basename)); } public function getBasenameProvider() diff --git a/tests/Components/HostTest.php b/tests/Components/HostTest.php index 6729eb4c2..11a13c74d 100644 --- a/tests/Components/HostTest.php +++ b/tests/Components/HostTest.php @@ -15,36 +15,36 @@ /** * @group host */ -class HostTest extends TestCase +final class HostTest extends TestCase { public function testDebugInfo() { $host = new Host('uri.thephpleague.com'); - $this->assertInternalType('array', $host->__debugInfo()); + self::assertInternalType('array', $host->__debugInfo()); } public function testSetState() { $host = new Host('uri.thephpleague.com'); - $this->assertSame('thephpleague.com', $host->getRegisterableDomain()); + self::assertSame('thephpleague.com', $host->getRegisterableDomain()); $generateHost = eval('return '.var_export($host, true).';'); - $this->assertEquals($host, $generateHost); + self::assertEquals($host, $generateHost); } public function testDefined() { $component = new Host('yolo'); - $this->assertFalse($component->isNull()); - $this->assertTrue($component->withContent(null)->isNull()); - $this->assertTrue($component->withContent(null)->isEmpty()); - $this->assertTrue($component->withContent('')->isEmpty()); + self::assertFalse($component->isNull()); + self::assertTrue($component->withContent(null)->isNull()); + self::assertTrue($component->withContent(null)->isEmpty()); + self::assertTrue($component->withContent('')->isEmpty()); } public function testWithContent() { $host = new Host('uri.thephpleague.com'); $alt_host = $host->withContent('uri.thephpleague.com'); - $this->assertSame($alt_host, $host); + self::assertSame($alt_host, $host); } public function testWithDomainResolver() @@ -52,14 +52,14 @@ public function testWithDomainResolver() $resolver = (new ICANNSectionManager(new Cache(), new CurlHttpClient()))->getRules(); $host = new Host('uri.thephpleague.com'); $newHost = $host->withDomainResolver($resolver); - $this->assertNotEquals($newHost, $host); + self::assertNotEquals($newHost, $host); } public function testWithDomainResolverOnSameResolver() { $host = new Host('uri.thephpleague.com'); $newHost = $host->withDomainResolver(); - $this->assertInstanceOf(Host::class, $host); + self::assertInstanceOf(Host::class, $host); } /** @@ -79,15 +79,15 @@ public function testWithDomainResolverOnSameResolver() public function testValidHost($host, $isDomain, $isIp, $isIpv4, $isIpv6, $isIpFuture, $ipVersion, $uri, $ip, $iri) { $host = new Host($host); - $this->assertSame($isDomain, $host->isDomain()); - $this->assertSame($isIp, $host->isIp()); - $this->assertSame($isIpv4, $host->isIpv4()); - $this->assertSame($isIpv6, $host->isIpv6()); - $this->assertSame($isIpFuture, $host->isIpFuture()); - $this->assertSame($uri, $host->getUriComponent()); - $this->assertSame($ip, $host->getIp()); - $this->assertSame($iri, $host->getContent(Host::RFC3987_ENCODING)); - $this->assertSame($ipVersion, $host->getIpVersion()); + self::assertSame($isDomain, $host->isDomain()); + self::assertSame($isIp, $host->isIp()); + self::assertSame($isIpv4, $host->isIpv4()); + self::assertSame($isIpv6, $host->isIpv6()); + self::assertSame($isIpFuture, $host->isIpFuture()); + self::assertSame($uri, $host->getUriComponent()); + self::assertSame($ip, $host->getIp()); + self::assertSame($iri, $host->getContent(Host::RFC3987_ENCODING)); + self::assertSame($ipVersion, $host->getIpVersion()); } public function validHostProvider() @@ -318,7 +318,7 @@ public function invalidHostProvider() */ public function testIsAbsolute($raw, $expected) { - $this->assertSame($expected, (new Host($raw))->isAbsolute()); + self::assertSame($expected, (new Host($raw))->isAbsolute()); } public function isAbsoluteProvider() @@ -340,8 +340,8 @@ public function isAbsoluteProvider() public function testValidUnicodeHost($unicode, $ascii) { $host = new Host($unicode); - $this->assertSame($ascii, $host->getContent(Host::RFC3986_ENCODING)); - $this->assertSame($unicode, $host->getContent(Host::RFC3987_ENCODING)); + self::assertSame($ascii, $host->getContent(Host::RFC3986_ENCODING)); + self::assertSame($unicode, $host->getContent(Host::RFC3987_ENCODING)); } public function hostnamesProvider() @@ -383,8 +383,8 @@ public function hostnamesProvider() public function testCountable($host, $nblabels, $array) { $obj = new Host($host); - $this->assertCount($nblabels, $obj); - $this->assertSame($array, $obj->getLabels()); + self::assertCount($nblabels, $obj); + self::assertSame($array, $obj->getLabels()); } public function countableProvider() @@ -406,7 +406,7 @@ public function countableProvider() */ public function testCreateFromLabels($input, $is_absolute, $expected) { - $this->assertSame($expected, (string) Host::createFromLabels($input, $is_absolute)); + self::assertSame($expected, (string) Host::createFromLabels($input, $is_absolute)); } public function createFromLabelsValid() @@ -449,7 +449,7 @@ public function createFromLabelsInvalid() */ public function testCreateFromIp($input, $expected) { - $this->assertSame($expected, (string) Host::createFromIp($input)); + self::assertSame($expected, (string) Host::createFromIp($input)); } public function createFromIpValid() @@ -484,18 +484,18 @@ public function createFromIpFailed() public function testGetLabel() { $host = new Host('master.example.com'); - $this->assertSame('com', $host->getLabel(0)); - $this->assertSame('example', $host->getLabel(1)); - $this->assertSame('master', $host->getLabel(-1)); - $this->assertNull($host->getLabel(23)); - $this->assertSame('toto', $host->getLabel(23, 'toto')); + self::assertSame('com', $host->getLabel(0)); + self::assertSame('example', $host->getLabel(1)); + self::assertSame('master', $host->getLabel(-1)); + self::assertNull($host->getLabel(23)); + self::assertSame('toto', $host->getLabel(23, 'toto')); } public function testOffsets() { $host = new Host('master.example.com'); - $this->assertSame([0, 1, 2], $host->keys()); - $this->assertSame([2], $host->keys('master')); + self::assertSame([0, 1, 2], $host->keys()); + self::assertSame([2], $host->keys('master')); } /** @@ -506,7 +506,7 @@ public function testOffsets() */ public function testWithout($host, $without, $res) { - $this->assertSame($res, (string) (new Host($host))->withoutLabels($without)); + self::assertSame($res, (string) (new Host($host))->withoutLabels($without)); } public function withoutProvider() @@ -534,7 +534,7 @@ public function testWithoutTriggersException() */ public function testWithoutZoneIdentifier($host, $expected) { - $this->assertSame($expected, (string) (new Host($host))->withoutZoneIdentifier()); + self::assertSame($expected, (string) (new Host($host))->withoutZoneIdentifier()); } public function withoutZoneIdentifierProvider() @@ -555,7 +555,7 @@ public function withoutZoneIdentifierProvider() */ public function testHasZoneIdentifier($host, $expected) { - $this->assertSame($expected, (new Host($host))->hasZoneIdentifier()); + self::assertSame($expected, (new Host($host))->hasZoneIdentifier()); } public function hasZoneIdentifierProvider() @@ -576,7 +576,7 @@ public function hasZoneIdentifierProvider() */ public function testPrepend($raw, $prepend, $expected) { - $this->assertSame($expected, (string) (new Host($raw))->prepend($prepend)); + self::assertSame($expected, (string) (new Host($raw))->prepend($prepend)); } public function validPrepend() @@ -604,7 +604,7 @@ public function testPrependIpFailed() */ public function testAppend($raw, $append, $expected) { - $this->assertSame($expected, (string) (new Host($raw))->append($append)); + self::assertSame($expected, (string) (new Host($raw))->append($append)); } public function validAppend() @@ -635,7 +635,7 @@ public function testAppendIpFailed() */ public function testReplace($raw, $input, $offset, $expected) { - $this->assertSame($expected, (new Host($raw))->replaceLabel($offset, $input)->__toString()); + self::assertSame($expected, (new Host($raw))->replaceLabel($offset, $input)->__toString()); } public function replaceValid() @@ -674,10 +674,10 @@ public function testPublicSuffixListImplementation( $isValidSuffix ) { $host = new Host($host); - $this->assertSame($subdomain, $host->getSubDomain()); - $this->assertSame($registerableDomain, $host->getRegisterableDomain()); - $this->assertSame($publicSuffix, $host->getPublicSuffix()); - $this->assertSame($isValidSuffix, $host->isPublicSuffixValid()); + self::assertSame($subdomain, $host->getSubDomain()); + self::assertSame($registerableDomain, $host->getRegisterableDomain()); + self::assertSame($publicSuffix, $host->getPublicSuffix()); + self::assertSame($isValidSuffix, $host->isPublicSuffixValid()); } public function parseDataProvider() @@ -702,7 +702,7 @@ public function parseDataProvider() */ public function testWithPublicSuffix($publicsuffix, $host, $expected) { - $this->assertSame( + self::assertSame( $expected, (string) (new Host($host))->withPublicSuffix($publicsuffix) ); @@ -710,7 +710,7 @@ public function testWithPublicSuffix($publicsuffix, $host, $expected) public function testWithPublicSuffixOnEmptySource() { - $this->assertSame( + self::assertSame( '', (string) (new Host(''))->withPublicSuffix('') ); @@ -720,7 +720,7 @@ public function testWithPublicSuffixOnInvalidHostName() { $this->expectException(\Exception::class); $this->expectExceptionMessage('The submitted host `.` is invalid'); - $this->assertSame( + self::assertSame( '', (string) (new Host('.'))->withPublicSuffix('.') ); @@ -752,7 +752,7 @@ public function testWithPublicSuffixThrowException() */ public function testWithRegisterableDomain($newhost, $host, $expected) { - $this->assertSame($expected, (string) (new Host($host))->withRegisterableDomain($newhost)); + self::assertSame($expected, (string) (new Host($host))->withRegisterableDomain($newhost)); } public function validRegisterableDomain() @@ -788,7 +788,7 @@ public function testWithSubDomainThrowExceptionWithAbsoluteRegisterableDomain() */ public function testWithSubDomain($new_subdomain, $host, $expected) { - $this->assertSame($expected, (string) (new Host($host))->withSubDomain($new_subdomain)); + self::assertSame($expected, (string) (new Host($host))->withSubDomain($new_subdomain)); } public function validSubDomain() @@ -827,8 +827,8 @@ public function testWithSubDomainThrowExceptionWithAbsoluteSubDomain() public function testWithRooot($host, $expected_with_root, $expected_without_root) { $host = new Host($host); - $this->assertSame($expected_with_root, (string) $host->withRootLabel()); - $this->assertSame($expected_without_root, (string) $host->withoutRootLabel()); + self::assertSame($expected_with_root, (string) $host->withRootLabel()); + self::assertSame($expected_without_root, (string) $host->withoutRootLabel()); } public function rootProvider() diff --git a/tests/Components/PathTest.php b/tests/Components/PathTest.php index 09c44b915..d221233db 100644 --- a/tests/Components/PathTest.php +++ b/tests/Components/PathTest.php @@ -10,7 +10,7 @@ * @group path * @group defaultpath */ -class PathTest extends TestCase +final class PathTest extends TestCase { /** * @dataProvider validPathEncoding @@ -22,11 +22,11 @@ class PathTest extends TestCase public function testGetUriComponent($raw, $parsed, $rfc1738) { $path = new Path($raw); - $this->assertSame($parsed, $path->getUriComponent()); - $this->assertSame($raw, $path->getContent(Path::RFC3987_ENCODING)); - $this->assertSame($raw, $path->getContent(Path::NO_ENCODING)); - $this->assertSame($rfc1738, $path->getContent(Path::RFC1738_ENCODING)); - $this->assertFalse($path->isNull()); + self::assertSame($parsed, $path->getUriComponent()); + self::assertSame($raw, $path->getContent(Path::RFC3987_ENCODING)); + self::assertSame($raw, $path->getContent(Path::NO_ENCODING)); + self::assertSame($rfc1738, $path->getContent(Path::RFC1738_ENCODING)); + self::assertFalse($path->isNull()); } public function validPathEncoding() @@ -49,9 +49,9 @@ public function validPathEncoding() public function testNullConstructor() { $path = new Path(); - $this->assertEquals(new Path(''), $path); - $this->assertFalse($path->isNull()); - $this->assertTrue($path->isEmpty()); + self::assertEquals(new Path(''), $path); + self::assertFalse($path->isNull()); + self::assertTrue($path->isEmpty()); } public function testInvalidEncodingTypeThrowException() @@ -63,7 +63,7 @@ public function testInvalidEncodingTypeThrowException() public function testDebugInfo() { $component = new Path('this is a normal path'); - $this->assertInternalType('array', $component->__debugInfo()); + self::assertInternalType('array', $component->__debugInfo()); } /** @@ -75,7 +75,7 @@ public function testDebugInfo() */ public function testWithoutDotSegments($path, $expected) { - $this->assertSame($expected, (new Path($path))->withoutDotSegments()->__toString()); + self::assertSame($expected, (new Path($path))->withoutDotSegments()->__toString()); } /** @@ -101,7 +101,7 @@ public function normalizeProvider() */ public function testWithoutEmptySegments($path, $expected) { - $this->assertSame($expected, (string) (new Path($path))->withoutEmptySegments()); + self::assertSame($expected, (string) (new Path($path))->withoutEmptySegments()); } public function withoutEmptySegmentsProvider() @@ -121,7 +121,7 @@ public function withoutEmptySegmentsProvider() */ public function testHasTrailingSlash($path, $expected) { - $this->assertSame($expected, (new Path($path))->hasTrailingSlash()); + self::assertSame($expected, (new Path($path))->hasTrailingSlash()); } public function trailingSlashProvider() @@ -143,7 +143,7 @@ public function trailingSlashProvider() */ public function testWithTrailingSlash($path, $expected) { - $this->assertSame($expected, (string) (new Path($path))->withTrailingSlash()); + self::assertSame($expected, (string) (new Path($path))->withTrailingSlash()); } public function withTrailingSlashProvider() @@ -165,7 +165,7 @@ public function withTrailingSlashProvider() */ public function testWithoutTrailingSlash($path, $expected) { - $this->assertSame($expected, (string) (new Path($path))->withoutTrailingSlash()); + self::assertSame($expected, (string) (new Path($path))->withoutTrailingSlash()); } public function withoutTrailingSlashProvider() @@ -187,7 +187,7 @@ public function withoutTrailingSlashProvider() */ public function testWithLeadingSlash($path, $expected) { - $this->assertSame($expected, (string) (new Path($path))->withLeadingSlash()); + self::assertSame($expected, (string) (new Path($path))->withLeadingSlash()); } public function withLeadingSlashProvider() @@ -209,7 +209,7 @@ public function withLeadingSlashProvider() */ public function testWithoutLeadingSlash($path, $expected) { - $this->assertSame($expected, (string) (new Path($path))->withoutLeadingSlash()); + self::assertSame($expected, (string) (new Path($path))->withoutLeadingSlash()); } public function withoutLeadingSlashProvider() diff --git a/tests/Components/PortTest.php b/tests/Components/PortTest.php index 92effebab..5b227be48 100644 --- a/tests/Components/PortTest.php +++ b/tests/Components/PortTest.php @@ -9,18 +9,18 @@ /** * @group port */ -class PortTest extends TestCase +final class PortTest extends TestCase { public function testPortSetter() { - $this->assertSame('443', (new Port(443))->__toString()); + self::assertSame('443', (new Port(443))->__toString()); } public function testSetState() { $component = new Port(42); $generateComponent = eval('return '.var_export($component, true).';'); - $this->assertEquals($component, $generateComponent); + self::assertEquals($component, $generateComponent); } /** @@ -30,7 +30,7 @@ public function testSetState() */ public function testToInt($input, $expected) { - $this->assertSame($expected, (new Port($input))->getContent()); + self::assertSame($expected, (new Port($input))->getContent()); } public function getToIntProvider() @@ -69,7 +69,7 @@ public function testFailedPort($port) */ public function testGetUriComponent($input, $expected) { - $this->assertSame($expected, (new Port($input))->getUriComponent()); + self::assertSame($expected, (new Port($input))->getUriComponent()); } public function getUriComponentProvider() diff --git a/tests/Components/QueryTest.php b/tests/Components/QueryTest.php index fbf8d2eed..47b106962 100644 --- a/tests/Components/QueryTest.php +++ b/tests/Components/QueryTest.php @@ -11,7 +11,7 @@ * @group query * @coversDefaultClass \League\Uri\Components\Query */ -class QueryTest extends TestCase +final class QueryTest extends TestCase { /** * @var Query @@ -29,7 +29,7 @@ protected function setUp() public function testSetState() { $generateComponent = eval('return '.var_export($this->query, true).';'); - $this->assertEquals($this->query, $generateComponent); + self::assertEquals($this->query, $generateComponent); } /** @@ -86,9 +86,9 @@ public function testSeparator() { $query = new Query('foo=bar&kingkong=toto'); $new_query = $query->withSeparator('|'); - $this->assertSame('&', $query->getSeparator()); - $this->assertSame('|', $new_query->getSeparator()); - $this->assertSame('foo=bar|kingkong=toto', $new_query->getContent()); + self::assertSame('&', $query->getSeparator()); + self::assertSame('|', $new_query->getSeparator()); + self::assertSame('foo=bar|kingkong=toto', $new_query->getContent()); } /** @@ -97,8 +97,8 @@ public function testSeparator() */ public function testDefined() { - $this->assertFalse($this->query->isNull()); - $this->assertTrue($this->query->withContent(null)->isNull()); + self::assertFalse($this->query->isNull()); + self::assertTrue($this->query->withContent(null)->isNull()); } /** @@ -106,7 +106,7 @@ public function testDefined() */ public function testDebugInfo() { - $this->assertInternalType('array', $this->query->__debugInfo()); + self::assertInternalType('array', $this->query->__debugInfo()); } /** @@ -114,7 +114,7 @@ public function testDebugInfo() */ public function testWithContent() { - $this->assertSame($this->query, $this->query->withContent('kingkong=toto')); + self::assertSame($this->query, $this->query->withContent('kingkong=toto')); } /** @@ -122,7 +122,7 @@ public function testWithContent() */ public function testIterator() { - $this->assertSame(['kingkong' => 'toto'], iterator_to_array($this->query, true)); + self::assertSame(['kingkong' => 'toto'], iterator_to_array($this->query, true)); } /** @@ -138,7 +138,7 @@ public function testGetUriComponent($input, $expected) { $query = is_array($input) ? Query::createFromPairs($input) : new Query($input); - $this->assertSame($expected, $query->getUriComponent()); + self::assertSame($expected, $query->getUriComponent()); } public function queryProvider() @@ -175,7 +175,7 @@ public function queryProvider() public function testcreateFromPairsWithTraversable() { $query = Query::createFromPairs(new ArrayIterator(['john' => 'doe the john'])); - $this->assertCount(1, $query); + self::assertCount(1, $query); } /** @@ -207,9 +207,9 @@ public function createFromPairsFailedProvider() */ public function testNormalization() { - $this->assertSame('foo=bar&=', (new Query('foo=bar&&&=&&&&&&'))->withoutEmptyPairs()->getContent()); - $this->assertSame('=bar&=', (new Query('&=bar&='))->withoutEmptyPairs()->getContent()); - $this->assertNull((new Query('&&&&&&&&&&&'))->withoutEmptyPairs()->getContent()); + self::assertSame('foo=bar&=', (new Query('foo=bar&&&=&&&&&&'))->withoutEmptyPairs()->getContent()); + self::assertSame('=bar&=', (new Query('&=bar&='))->withoutEmptyPairs()->getContent()); + self::assertNull((new Query('&&&&&&&&&&&'))->withoutEmptyPairs()->getContent()); } /** @@ -224,7 +224,7 @@ public function testNormalization() public function testMerge(string $base_query, string $query, string $expected) { $base = new Query($base_query); - $this->assertSame($expected, $base->merge($query)->getContent()); + self::assertSame($expected, $base->merge($query)->getContent()); } public function mergeDataProvider() @@ -305,7 +305,7 @@ public function mergeDataProvider() public function testAppend($query, $append_data, $expected) { $base = new Query($query); - $this->assertSame($expected, $base->append($append_data)->getContent()); + self::assertSame($expected, $base->append($append_data)->getContent()); } public function validAppendValue() @@ -336,9 +336,9 @@ public function validAppendValue() public function testGetParameter() { $expected = 'toofan'; - $this->assertSame($expected, $this->query->getPair('togo', $expected)); - $this->assertNull($this->query->getPair('togo')); - $this->assertSame('toto', $this->query->getPair('kingkong')); + self::assertSame($expected, $this->query->getPair('togo', $expected)); + self::assertNull($this->query->getPair('togo')); + self::assertSame('toto', $this->query->getPair('kingkong')); } /** @@ -346,8 +346,8 @@ public function testGetParameter() */ public function testHas() { - $this->assertTrue($this->query->hasPair('kingkong')); - $this->assertFalse($this->query->hasPair('togo')); + self::assertTrue($this->query->hasPair('kingkong')); + self::assertFalse($this->query->hasPair('togo')); } /** @@ -355,7 +355,7 @@ public function testHas() */ public function testCountable() { - $this->assertCount(1, $this->query); + self::assertCount(1, $this->query); } /** @@ -370,12 +370,12 @@ public function testKeys() 'toto' => 'troll', 'yolo' => null, ]); - $this->assertCount(0, $query->keys('foo')); - $this->assertSame(['foo'], $query->keys('bar')); - $this->assertCount(1, $query->keys('3')); - $this->assertSame(['lol'], $query->keys('3')); - $this->assertSame(['baz', 'toto'], $query->keys('troll')); - $this->assertSame(['yolo'], $query->keys(null)); + self::assertCount(0, $query->keys('foo')); + self::assertSame(['foo'], $query->keys('bar')); + self::assertCount(1, $query->keys('3')); + self::assertSame(['lol'], $query->keys('3')); + self::assertSame(['baz', 'toto'], $query->keys('troll')); + self::assertSame(['yolo'], $query->keys(null)); } /** @@ -385,11 +385,11 @@ public function testStringWithoutContent() { $query = new Query('foo&bar&baz'); - $this->assertCount(3, $query->keys()); - $this->assertSame(['foo', 'bar', 'baz'], $query->keys()); - $this->assertNull($query->getPair('foo')); - $this->assertNull($query->getPair('bar')); - $this->assertNull($query->getPair('baz')); + self::assertCount(3, $query->keys()); + self::assertSame(['foo', 'bar', 'baz'], $query->keys()); + self::assertNull($query->getPair('foo')); + self::assertNull($query->getPair('bar')); + self::assertNull($query->getPair('baz')); } /** @@ -399,7 +399,7 @@ public function testGetPairs() { $expected = ['foo' => null, 'bar' => null, 'baz' => null, 'to.go' => 'toofan']; $query = new Query('foo&bar&baz&to.go=toofan'); - $this->assertSame($expected, $query->getPairs()); + self::assertSame($expected, $query->getPairs()); } /** @@ -410,7 +410,7 @@ public function testGetPairs() */ public function testGetParams($query, $expected) { - $this->assertSame($expected, (new Query($query))->getParams()); + self::assertSame($expected, (new Query($query))->getParams()); } /** @@ -423,7 +423,7 @@ public function testGetParams($query, $expected) */ public function testGetParam($query, $offset, $default, $expected) { - $this->assertSame($expected, (new Query($query))->getParam($offset, $default)); + self::assertSame($expected, (new Query($query))->getParam($offset, $default)); } public function getParamProvider() @@ -455,7 +455,7 @@ public function getParamProvider() */ public function testWithoutPairs($origin, $without, $result) { - $this->assertSame($result, (string) (new Query($origin))->withoutPairs($without)); + self::assertSame($result, (string) (new Query($origin))->withoutPairs($without)); } public function withoutPairsProvider() @@ -479,7 +479,7 @@ public function withoutPairsProvider() */ public function testWithoutParams(array $origin, array $without, string $expected) { - $this->assertSame($expected, (string) (Query::createFromParams($origin))->withoutParams($without)); + self::assertSame($expected, (string) (Query::createFromParams($origin))->withoutParams($without)); } public function withoutParamsProvider() @@ -543,10 +543,10 @@ public function testWithoutParamsDoesNotChangeParamsKey() ]; $query = Query::createFromParams($data); - $this->assertSame('foo%5B0%5D=bar&foo%5B1%5D=baz', $query->getContent()); + self::assertSame('foo%5B0%5D=bar&foo%5B1%5D=baz', $query->getContent()); $new_query = $query->withoutParams(['foo[0]']); - $this->assertSame('foo%5B1%5D=baz', $new_query->getContent()); - $this->assertSame(['foo' => [1 => 'baz']], $new_query->getParams()); + self::assertSame('foo%5B1%5D=baz', $new_query->getContent()); + self::assertSame(['foo' => [1 => 'baz']], $new_query->getParams()); } /** @@ -588,14 +588,14 @@ public function testWithoutNumericIndices() ]; $query = Query::createFromParams($data); - $this->assertSame($with_indices['string'], $query->getContent()); - $this->assertSame($with_indices['pairs'], $query->getPairs()); - $this->assertSame($data, $query->getParams()); + self::assertSame($with_indices['string'], $query->getContent()); + self::assertSame($with_indices['pairs'], $query->getPairs()); + self::assertSame($data, $query->getParams()); $new_query = $query->withoutNumericIndices(); - $this->assertSame($without_indices['string'], $new_query->getContent()); - $this->assertSame($without_indices['pairs'], $new_query->getPairs()); - $this->assertSame($data, $new_query->getParams()); + self::assertSame($without_indices['string'], $new_query->getContent()); + self::assertSame($without_indices['pairs'], $new_query->getPairs()); + self::assertSame($data, $new_query->getParams()); } /** @@ -604,7 +604,7 @@ public function testWithoutNumericIndices() */ public function testWithoutNumericIndicesRetursSameInstance() { - $this->assertSame($this->query->withoutNumericIndices(), $this->query); + self::assertSame($this->query->withoutNumericIndices(), $this->query); } /** @@ -614,7 +614,7 @@ public function testWithoutNumericIndicesRetursSameInstance() public function testWithoutNumericIndicesDoesNotAffectPairValue() { $query = Query::createFromParams(['foo' => 'bar[3]']); - $this->assertSame($query, $query->withoutNumericIndices()); + self::assertSame($query, $query->withoutNumericIndices()); } /** @@ -623,7 +623,7 @@ public function testWithoutNumericIndicesDoesNotAffectPairValue() public function testCreateFromParamsOnEmptyParams() { $query = Query::createFromParams([]); - $this->assertSame($query, $query->withoutNumericIndices()); + self::assertSame($query, $query->withoutNumericIndices()); } /** @@ -632,7 +632,7 @@ public function testCreateFromParamsOnEmptyParams() public function testIsEmpty() { $query = Query::createFromParams([]); - $this->assertTrue($query->isEmpty()); + self::assertTrue($query->isEmpty()); } /** @@ -641,7 +641,7 @@ public function testIsEmpty() public function testGetContentOnEmptyContent() { $query = Query::createFromParams([]); - $this->assertNull($query->getContent()); + self::assertNull($query->getContent()); } /** @@ -650,7 +650,7 @@ public function testGetContentOnEmptyContent() public function testGetContentOnHavingContent() { $query = Query::createFromParams(['foo' => 'bar']); - $this->assertSame('foo=bar', $query->getContent()); + self::assertSame('foo=bar', $query->getContent()); } /** @@ -659,7 +659,7 @@ public function testGetContentOnHavingContent() public function testGetContentOnToString() { $query = Query::createFromParams(['foo' => 'bar']); - $this->assertSame('foo=bar', (string) $query); + self::assertSame('foo=bar', (string) $query); } /** @@ -668,7 +668,7 @@ public function testGetContentOnToString() public function testWithSeperatorOnHavingSeparator() { $query = Query::createFromParams(['foo' => '/bar']); - $this->assertInstanceOf(Query::class, $query->withSeparator('&')); + self::assertInstanceOf(Query::class, $query->withSeparator('&')); } /** @@ -677,7 +677,7 @@ public function testWithSeperatorOnHavingSeparator() public function testWithoutNumericIndicesOnEmptyContent() { $query = Query::createFromParams([]); - $this->assertInstanceOf(Query::class, $query->withoutNumericIndices()); + self::assertInstanceOf(Query::class, $query->withoutNumericIndices()); } /** @@ -689,7 +689,7 @@ public function testWithoutNumericIndicesOnEmptyContent() */ public function testksort($data, $sort, $expected) { - $this->assertSame($expected, Query::createFromPairs($data)->ksort($sort)->getPairs()); + self::assertSame($expected, Query::createFromPairs($data)->ksort($sort)->getPairs()); } public function ksortProvider() @@ -727,7 +727,7 @@ function ($dataA, $dataB) { */ public function testParse($query, $separator, $expected, $encoding) { - $this->assertSame($expected, Query::parse($query, $separator, $encoding)); + self::assertSame($expected, Query::parse($query, $separator, $encoding)); } public function parserProvider() @@ -857,11 +857,11 @@ public function testBuild( $expected_iri, $expected_no_encoding ) { - $this->assertSame($expected_rfc1738, Query::build($pairs, '&', Query::RFC1738_ENCODING)); - $this->assertSame($expected_rfc3986, Query::build($pairs, '&', Query::RFC3986_ENCODING)); - $this->assertSame($expected_rfc3987, Query::build($pairs, '&', Query::RFC3987_ENCODING)); - $this->assertSame($expected_no_encoding, Query::build($pairs, '&', Query::NO_ENCODING)); - $this->assertSame($expected_iri, Query::createFromPairs($pairs)->getContent(Query::RFC3987_ENCODING)); + self::assertSame($expected_rfc1738, Query::build($pairs, '&', Query::RFC1738_ENCODING)); + self::assertSame($expected_rfc3986, Query::build($pairs, '&', Query::RFC3986_ENCODING)); + self::assertSame($expected_rfc3987, Query::build($pairs, '&', Query::RFC3987_ENCODING)); + self::assertSame($expected_no_encoding, Query::build($pairs, '&', Query::NO_ENCODING)); + self::assertSame($expected_iri, Query::createFromPairs($pairs)->getContent(Query::RFC3987_ENCODING)); } public function buildProvider() @@ -987,7 +987,7 @@ public function buildProvider() */ public function testBuildWithMalformedUtf8Chars() { - $this->assertSame( + self::assertSame( 'badutf8=%A0TM1TMS061114IP1', Query::build(['badutf8' => rawurldecode('%A0TM1TMS061114IP1')]) ); @@ -1028,7 +1028,7 @@ public function testFailSafeQueryParsing() $arr = ['a' => '1', 'b' => 'le heros']; $expected = 'a=1&b=le%20heros'; - $this->assertSame($expected, Query::build($arr, '&')); + self::assertSame($expected, Query::build($arr, '&')); } /** @@ -1038,8 +1038,8 @@ public function testParserBuilderPreserveQuery() { $querystring = 'uri=http://example.com?a=b%26c=d'; $data = Query::parse($querystring); - $this->assertSame(['uri' => 'http://example.com?a=b&c=d'], $data); - $this->assertSame($querystring, Query::build($data)); + self::assertSame(['uri' => 'http://example.com?a=b&c=d'], $data); + self::assertSame($querystring, Query::build($data)); } /** @@ -1050,7 +1050,7 @@ public function testParserBuilderPreserveQuery() */ public function testParsedQuery($query, $expectedData) { - $this->assertSame($expectedData, Query::extract($query)); + self::assertSame($expectedData, Query::extract($query)); } public function parsedQueryProvider() diff --git a/tests/Components/SchemeTest.php b/tests/Components/SchemeTest.php index e3c859619..e9e0ddcbb 100644 --- a/tests/Components/SchemeTest.php +++ b/tests/Components/SchemeTest.php @@ -9,28 +9,28 @@ /** * @group scheme */ -class SchemeTest extends TestCase +final class SchemeTest extends TestCase { public function testSetState() { $component = new Scheme('ignace'); $generateComponent = eval('return '.var_export($component, true).';'); - $this->assertEquals($component, $generateComponent); + self::assertEquals($component, $generateComponent); } public function testWithValue() { $scheme = new Scheme('ftp'); $http_scheme = $scheme->withContent('HTTP'); - $this->assertSame('http', $http_scheme->__toString()); - $this->assertSame('http:', $http_scheme->getUriComponent()); + self::assertSame('http', $http_scheme->__toString()); + self::assertSame('http:', $http_scheme->getUriComponent()); } public function testEmptyScheme() { $scheme = new Scheme(); - $this->assertSame('', (string) $scheme); - $this->assertSame('', $scheme->getUriComponent()); + self::assertSame('', (string) $scheme); + self::assertSame('', $scheme->getUriComponent()); } /** @@ -40,7 +40,7 @@ public function testEmptyScheme() */ public function testValidScheme($scheme, $toString) { - $this->assertSame($toString, (new Scheme($scheme))->__toString()); + self::assertSame($toString, (new Scheme($scheme))->__toString()); } public function validSchemeProvider() diff --git a/tests/Components/UserInfoTest.php b/tests/Components/UserInfoTest.php index aff17a7b8..b027b0e14 100644 --- a/tests/Components/UserInfoTest.php +++ b/tests/Components/UserInfoTest.php @@ -9,12 +9,12 @@ /** * @group userinfo */ -class UserInfoTest extends TestCase +final class UserInfoTest extends TestCase { public function testDebugInfo() { $component = new UserInfo('yolo', 'oloy'); - $this->assertInternalType('array', $component->__debugInfo()); + self::assertInternalType('array', $component->__debugInfo()); } /** @@ -39,12 +39,12 @@ public function testConstructor( $rfc1738_str ) { $userinfo = new UserInfo($user, $pass); - $this->assertSame($expected_user, $userinfo->getUser()); - $this->assertSame($expected_pass, $userinfo->getPass()); - $this->assertSame($expected_str, (string) $userinfo); - $this->assertSame($uri_component, $userinfo->getUriComponent()); - $this->assertSame($iri_str, $userinfo->getContent(UserInfo::RFC3987_ENCODING)); - $this->assertSame($rfc1738_str, $userinfo->getContent(UserInfo::RFC1738_ENCODING)); + self::assertSame($expected_user, $userinfo->getUser()); + self::assertSame($expected_pass, $userinfo->getPass()); + self::assertSame($expected_str, (string) $userinfo); + self::assertSame($uri_component, $userinfo->getUriComponent()); + self::assertSame($iri_str, $userinfo->getContent(UserInfo::RFC3987_ENCODING)); + self::assertSame($rfc1738_str, $userinfo->getContent(UserInfo::RFC1738_ENCODING)); } public function userInfoProvider() @@ -136,14 +136,14 @@ public function userInfoProvider() public function testIsNull() { - $this->assertTrue((new UserInfo(null))->isNull()); - $this->assertFalse((new UserInfo(''))->isNull()); + self::assertTrue((new UserInfo(null))->isNull()); + self::assertFalse((new UserInfo(''))->isNull()); } public function testIsEmpty() { - $this->assertTrue((new UserInfo(null))->isEmpty()); - $this->assertTrue((new UserInfo(''))->isEmpty()); + self::assertTrue((new UserInfo(null))->isEmpty()); + self::assertTrue((new UserInfo(''))->isEmpty()); } /** @@ -156,9 +156,9 @@ public function testIsEmpty() public function testWithContent($str, $expected_user, $expected_pass, $expected_str) { $conn = (new UserInfo())->withContent($str); - $this->assertSame($expected_user, $conn->getUser()); - $this->assertSame($expected_pass, $conn->getPass()); - $this->assertSame($expected_str, (string) $conn); + self::assertSame($expected_user, $conn->getUser()); + self::assertSame($expected_pass, $conn->getPass()); + self::assertSame($expected_str, (string) $conn); } public function createFromStringProvider() @@ -177,17 +177,17 @@ public function createFromStringProvider() public function testWithContentReturnSameInstance() { $conn = new UserInfo(); - $this->assertEquals($conn, $conn->withContent(':pass')); + self::assertEquals($conn, $conn->withContent(':pass')); $conn = new UserInfo('user', 'pass'); - $this->assertSame($conn, $conn->withContent('user:pass')); + self::assertSame($conn, $conn->withContent('user:pass')); } public function testSetState() { $conn = new UserInfo('user', 'pass'); $generateConn = eval('return '.var_export($conn, true).';'); - $this->assertEquals($conn, $generateConn); + self::assertEquals($conn, $generateConn); } /** @@ -198,7 +198,7 @@ public function testSetState() */ public function testWithUserInfo($user, $pass, $expected) { - $this->assertSame($expected, (string) (new UserInfo('user', 'pass'))->withUserInfo($user, $pass)); + self::assertSame($expected, (string) (new UserInfo('user', 'pass'))->withUserInfo($user, $pass)); } public function withUserInfoProvider() diff --git a/tests/FunctionsTest.php b/tests/FunctionsTest.php index 8bceacc22..098391100 100644 --- a/tests/FunctionsTest.php +++ b/tests/FunctionsTest.php @@ -13,7 +13,7 @@ * @group function * @group parser */ -class FunctionsTest extends TestCase +final class FunctionsTest extends TestCase { public function testEncodingThrowsExceptionWithQueryParser() { @@ -31,7 +31,7 @@ public function testQuerParserConvert() { $expected = ['a' => ['1', '2', 'false']]; $pairs = new ArrayIterator(['a[]' => [1, '2', false]]); - $this->assertSame($expected, (new Uri\QueryParser())->convert($pairs)); + self::assertSame($expected, (new Uri\QueryParser())->convert($pairs)); } /** @@ -61,7 +61,7 @@ public function invalidPairsProvider() */ public function testExtractQuery($query, $expectedData) { - $this->assertSame($expectedData, Uri\extract_query($query)); + self::assertSame($expectedData, Uri\extract_query($query)); } public function extractQueryProvider() @@ -134,7 +134,7 @@ public function extractQueryProvider() */ public function testParse($query, $separator, $expected, $encoding) { - $this->assertSame($expected, Uri\parse_query($query, $separator, $encoding)); + self::assertSame($expected, Uri\parse_query($query, $separator, $encoding)); } public function parserProvider() @@ -260,10 +260,10 @@ public function testBuild( $expected_rfc3987, $expected_no_encoding ) { - $this->assertSame($expected_rfc1738, Uri\build_query($pairs, '&', PHP_QUERY_RFC1738)); - $this->assertSame($expected_rfc3986, Uri\build_query($pairs, '&', PHP_QUERY_RFC3986)); - $this->assertSame($expected_rfc3987, Uri\build_query($pairs, '&', Query::RFC3987_ENCODING)); - $this->assertSame($expected_no_encoding, Uri\build_query($pairs, '&', Query::NO_ENCODING)); + self::assertSame($expected_rfc1738, Uri\build_query($pairs, '&', PHP_QUERY_RFC1738)); + self::assertSame($expected_rfc3986, Uri\build_query($pairs, '&', PHP_QUERY_RFC3986)); + self::assertSame($expected_rfc3987, Uri\build_query($pairs, '&', Query::RFC3987_ENCODING)); + self::assertSame($expected_no_encoding, Uri\build_query($pairs, '&', Query::NO_ENCODING)); } public function buildProvider()