From d3915a5c8884f53a4f5ed144018de63ba0f96dff Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 20 Aug 2019 15:20:15 +0200 Subject: [PATCH 01/13] updated --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index ef9127d..7ae3fd5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ init: install: - cd c:\ - - curl -fsS -o php.zip https://windows.php.net/downloads/releases/php-7.2.20-nts-Win32-VC15-x86.zip + - curl -fsS -o php.zip https://windows.php.net/downloads/releases/php-7.2.21-nts-Win32-VC15-x86.zip - 7z x php.zip -oc:\php > nul - cd c:\php - copy php.ini-production php.ini From 860fffd7c4378507ada4f472e134296400c90d72 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 20 Aug 2019 15:21:09 +0200 Subject: [PATCH 02/13] added tests for lower dependencies --- .travis.yml | 21 ++++++++++++++------- CHANGELOG.md | 3 +++ composer.json | 2 +- version | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6cfb626..d63cc7f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,20 +11,27 @@ matrix: fast_finish: true include: + - php: 5.6 + env: dependencies=lowest + - php: 7.0 + env: dependencies=lowest + - php: 7.1 + env: dependencies=lowest + - php: 7.2 + env: dependencies=lowest + - php: 7.3 + env: dependencies=lowest - php: 7.0 env: PHPCS=1 - - php: 7.0 env: COVERAGE=1 - - php: 7.0 - env: CAKEPHP_VERSION="3.7.*" - install: - - composer self-update + - composer self-update -q - composer install --prefer-dist --no-interaction - - if [[ ! -z "$CAKEPHP_VERSION" ]]; then composer require --update-with-dependencies cakephp/cakephp:${CAKEPHP_VERSION}; fi - + - if [ "$dependencies" = "lowest" ]; then composer update --prefer-lowest -n; fi; + - composer show -i + script: - if [[ $PHPCS != '1' && $COVERAGE != '1' ]]; then vendor/bin/phpunit; fi - if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs --standard=phpcs.xml.dist; fi diff --git a/CHANGELOG.md b/CHANGELOG.md index bd56163..c5da264 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # 1.x branch ## 1.0 branch +### 1.0.7 +* added tests for lower dependencies. + ### 1.0.6 * `LinkScanner::import()` can no longer be called statically; * little fixes; diff --git a/composer.json b/composer.json index 738354d..2fda4b9 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "cakephp/cakephp-codesniffer": "^3.0", - "phpunit/phpunit": "^5.7|^6.0" + "phpunit/phpunit": "^5.7.14|^6.0" }, "autoload": { "psr-4": { diff --git a/version b/version index af0b7dd..238d6e8 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.0.6 +1.0.7 From 91884f1251386da311f10e81709ce414073aa6a8 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 20 Aug 2019 15:26:46 +0200 Subject: [PATCH 03/13] no longer uses `File` and `Folder` classes --- CHANGELOG.md | 3 ++- src/Utility/LinkScanner.php | 14 ++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c5da264..6782d0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # 1.x branch ## 1.0 branch ### 1.0.7 -* added tests for lower dependencies. +* added tests for lower dependencies; +* no longer uses `File` and `Folder` classes. ### 1.0.6 * `LinkScanner::import()` can no longer be called statically; diff --git a/src/Utility/LinkScanner.php b/src/Utility/LinkScanner.php index 62fc2c1..2f16fd4 100644 --- a/src/Utility/LinkScanner.php +++ b/src/Utility/LinkScanner.php @@ -18,8 +18,6 @@ use Cake\Core\InstanceConfigTrait; use Cake\Event\EventDispatcherTrait; use Cake\Event\EventList; -use Cake\Filesystem\File; -use Cake\Filesystem\Folder; use Cake\Http\Client; use Cake\Http\Client\Response; use Exception; @@ -146,7 +144,7 @@ protected function _createLockFile() $this->lockFile ), RuntimeException::class); - return $this->getConfig('lockFile') ? new File($this->lockFile, true) !== false : true; + return $this->getConfig('lockFile') ? create_file($this->lockFile) !== false : true; } /** @@ -384,10 +382,8 @@ public function export($filename = null) ); $filename = $filename ?: sprintf('results_%s_%s', $this->hostname, $this->startTime); - if (!Folder::isAbsolute($filename)) { - $filename = add_slash_term($this->getConfig('target')) . $filename; - } - (new File($filename, true))->write(serialize($this)); + $filename = is_absolute($filename) ? $filename : add_slash_term($this->getConfig('target')) . $filename; + create_file($filename, serialize($this)); $this->dispatchEvent('LinkScanner.resultsExported', [$filename]); return $filename; @@ -408,9 +404,7 @@ public function export($filename = null) public function import($filename) { try { - if (!Folder::isAbsolute($filename)) { - $filename = add_slash_term($this->getConfig('target')) . $filename; - } + $filename = is_absolute($filename) ? $filename : add_slash_term($this->getConfig('target')) . $filename; $instance = unserialize(file_get_contents($filename)); } catch (Exception $e) { $message = preg_replace('/^file_get_contents\([\/\w\d:\-\\\\]+\): /', null, $e->getMessage()); From 5a4e71f7d217de70c6a627cd8418dc2fbdff0e15 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 20 Aug 2019 15:31:31 +0200 Subject: [PATCH 04/13] fixed --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 2fda4b9..38b6e0b 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ "require": { "php": ">=5.5.9", "cakephp/cakephp": "^3.7.1", - "mirko-pagliai/me-tools": "^2.18", + "mirko-pagliai/me-tools": "^2.18.9", "mirko-pagliai/php-tools": "^1.2.6" }, "require-dev": { From 02dda11602aa4b5edb2697af2f7999aafd7050d8 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 10 Sep 2019 15:53:24 +0200 Subject: [PATCH 05/13] updated --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 7ae3fd5..8e58dfc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,7 @@ init: install: - cd c:\ - - curl -fsS -o php.zip https://windows.php.net/downloads/releases/php-7.2.21-nts-Win32-VC15-x86.zip + - curl -fsS -o php.zip https://windows.php.net/downloads/releases/php-7.2.22-nts-Win32-VC15-x86.zip - 7z x php.zip -oc:\php > nul - cd c:\php - copy php.ini-production php.ini From 53f03c2083623f7a049efe40f7477a043c7062d2 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 10 Sep 2019 16:31:36 +0200 Subject: [PATCH 06/13] added `_getAbsolutePath()` method --- src/Utility/LinkScanner.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Utility/LinkScanner.php b/src/Utility/LinkScanner.php index 2f16fd4..f90ddae 100644 --- a/src/Utility/LinkScanner.php +++ b/src/Utility/LinkScanner.php @@ -26,6 +26,7 @@ use LinkScanner\ScanEntity; use RuntimeException; use Serializable; +use Symfony\Component\Filesystem\Filesystem; use Tools\BodyParser; use Zend\Diactoros\Stream; @@ -147,6 +148,19 @@ protected function _createLockFile() return $this->getConfig('lockFile') ? create_file($this->lockFile) !== false : true; } + /** + * Internal method to get the absolute path for a filename + * @param string $filename Filename + * @return string + * @since 1.0.7 + */ + protected function _getAbsolutePath($filename) + { + $isAbsolute = (new Filesystem())->isAbsolutePath($filename); + + return $isAbsolute ? $filename : add_slash_term($this->getConfig('target')) . $filename; + } + /** * Performs a single GET request and returns a `ScanResponse` instance. * @@ -369,6 +383,7 @@ public function unserialize($serialized) * @return string * @see serialize() * @throws \RuntimeException + * @uses _getAbsolutePath() * @uses $ResultScan * @uses $hostname * @uses $startTime @@ -381,8 +396,7 @@ public function export($filename = null) RuntimeException::class ); - $filename = $filename ?: sprintf('results_%s_%s', $this->hostname, $this->startTime); - $filename = is_absolute($filename) ? $filename : add_slash_term($this->getConfig('target')) . $filename; + $filename = $this->_getAbsolutePath($filename ?: sprintf('results_%s_%s', $this->hostname, $this->startTime)); create_file($filename, serialize($this)); $this->dispatchEvent('LinkScanner.resultsExported', [$filename]); @@ -399,12 +413,14 @@ public function export($filename = null) * been exported. * @param string $filename Filename from which to import * @return \LinkScanner\Utility\LinkScanner + * @uses _getAbsolutePath() * @throws \RuntimeException */ public function import($filename) { + $filename = $this->_getAbsolutePath($filename); + try { - $filename = is_absolute($filename) ? $filename : add_slash_term($this->getConfig('target')) . $filename; $instance = unserialize(file_get_contents($filename)); } catch (Exception $e) { $message = preg_replace('/^file_get_contents\([\/\w\d:\-\\\\]+\): /', null, $e->getMessage()); From e90b96afee4ae88c00ef887b43754462db7b14da Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 10 Sep 2019 16:32:33 +0200 Subject: [PATCH 07/13] some fixes --- .travis.yml | 2 +- README.md | 10 ++++---- src/Event/LinkScannerCommandEventListener.php | 18 +++++++------- src/TestSuite/TestCase.php | 15 +++++++----- tests/TestCase/Utility/LinkScannerTest.php | 24 +++++++++---------- 5 files changed, 36 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index d63cc7f..a7acee8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ script: - if [[ $PHPCS != '1' && $COVERAGE != '1' ]]; then vendor/bin/phpunit; fi - if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs --standard=phpcs.xml.dist; fi - if [[ $COVERAGE = 1 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi - + after_success: - if [[ $COVERAGE = 1 ]]; then bash <(curl -s https://codecov.io/bash); fi diff --git a/README.md b/README.md index 1b775a4..3deda2c 100644 --- a/README.md +++ b/README.md @@ -42,15 +42,15 @@ to indicate the full base url which to start the scan every time. ## How to use Please, refer to the wiki: -- [How to use the LinkScanner utility](//github.com/mirko-pagliai/cakephp-link-scanner/wiki/How-to-use-the-LinkScanner-utility) -- [How to use the LinkScannerCommand](//github.com/mirko-pagliai/cakephp-link-scanner/wiki/How-to-use-the-LinkScannerCommand) -- [Examples for ResultScan](//github.com/mirko-pagliai/cakephp-link-scanner/wiki/Examples-for-ResultScan) +* [How to use the LinkScanner utility](//github.com/mirko-pagliai/cakephp-link-scanner/wiki/How-to-use-the-LinkScanner-utility) +* [How to use the LinkScannerCommand](//github.com/mirko-pagliai/cakephp-link-scanner/wiki/How-to-use-the-LinkScannerCommand) +* [Examples for ResultScan](//github.com/mirko-pagliai/cakephp-link-scanner/wiki/Examples-for-ResultScan) In addition, you can refer to our [API](//mirko-pagliai.github.io/cakephp-link-scanner). ## To do list -* allow the use of a configuration file for the shell; -* allow to export results as html and/or xml. +* allow the use of a configuration file for the shell; +* allow to export results as html and/or xml. ## Versioning For transparency and insight into our release cycle and to maintain backward diff --git a/src/Event/LinkScannerCommandEventListener.php b/src/Event/LinkScannerCommandEventListener.php index 9a86c64..3f00f24 100644 --- a/src/Event/LinkScannerCommandEventListener.php +++ b/src/Event/LinkScannerCommandEventListener.php @@ -226,23 +226,23 @@ public function scanStarted(Event $event, $startTime, $fullBaseUrl) $this->io->info(__d('link-scanner', 'The cache is disabled')); } + $message = __d('link-scanner', 'Force mode is not enabled'); if ($this->args->getOption('force')) { - $this->io->info(__d('link-scanner', 'Force mode is enabled')); - } else { - $this->io->info(__d('link-scanner', 'Force mode is not enabled')); + $message = __d('link-scanner', 'Force mode is enabled'); } + $this->io->info($message); + $message = __d('link-scanner', 'Scanning of external links is not enabled'); if ($event->getSubject()->getConfig('externalLinks')) { - $this->io->info(__d('link-scanner', 'Scanning of external links is enabled')); - } else { - $this->io->info(__d('link-scanner', 'Scanning of external links is not enabled')); + $message = __d('link-scanner', 'Scanning of external links is enabled'); } + $this->io->info($message); + $message = __d('link-scanner', 'Redirects will not be followed'); if ($event->getSubject()->getConfig('followRedirects')) { - $this->io->info(__d('link-scanner', 'Redirects will be followed')); - } else { - $this->io->info(__d('link-scanner', 'Redirects will not be followed')); + $message = __d('link-scanner', 'Redirects will be followed'); } + $this->io->info($message); $maxDepth = $event->getSubject()->getConfig('maxDepth'); if (is_positive($maxDepth)) { diff --git a/src/TestSuite/TestCase.php b/src/TestSuite/TestCase.php index 4e59f03..69d0b56 100644 --- a/src/TestSuite/TestCase.php +++ b/src/TestSuite/TestCase.php @@ -88,18 +88,21 @@ protected function getClientReturnsSampleResponse() $Client->method('get')->will($this->returnCallback(function ($url) { $responseFile = TESTS . 'examples' . DS . 'responses' . DS . 'google_response'; $bodyFile = TESTS . 'examples' . DS . 'responses' . DS . 'google_body'; + $getResponse = function () use ($url) { + return (new Client(['redirect' => true]))->get($url); + }; if (is_readable($responseFile)) { - $response = @unserialize(file_get_contents($responseFile)); - } else { - $response = (new Client(['redirect' => true]))->get($url); + $getResponse = function () use ($responseFile) { + return @unserialize(file_get_contents($responseFile)); + }; } - is_readable($responseFile) ? null : file_put_contents($responseFile, serialize($response)); + is_readable($responseFile) ? null : file_put_contents($responseFile, serialize($getResponse())); - $body = is_readable($bodyFile) ? @unserialize(file_get_contents($bodyFile)) : (string)$response->getBody(); + $body = is_readable($bodyFile) ? @unserialize(file_get_contents($bodyFile)) : (string)$getResponse()->getBody(); is_readable($bodyFile) ? null : file_put_contents($bodyFile, serialize($body)); - return $this->getResponseWithBody($body, $response); + return $this->getResponseWithBody($body, $getResponse()); })); return $Client; diff --git a/tests/TestCase/Utility/LinkScannerTest.php b/tests/TestCase/Utility/LinkScannerTest.php index 439e468..e64a785 100644 --- a/tests/TestCase/Utility/LinkScannerTest.php +++ b/tests/TestCase/Utility/LinkScannerTest.php @@ -174,8 +174,8 @@ public function testExport() null => $this->LinkScanner->getConfig('target') . DS . 'results_' . $this->LinkScanner->hostname . '_' . $this->LinkScanner->startTime, 'example' => $this->LinkScanner->getConfig('target') . DS . 'example', TMP . 'example' => TMP . 'example', - ] as $filenameWhereToExport => $expectedFilename) { - $result = $this->LinkScanner->export($filenameWhereToExport); + ] as $filename => $expectedFilename) { + $result = $this->LinkScanner->export($filename); $this->assertFileExists($result); $this->assertEquals($expectedFilename, $result); $this->assertEventFired('LinkScanner.resultsExported', $this->EventManager); @@ -373,7 +373,7 @@ public function testScanFromTests() $this->assertEquals($expectedDebug, $this->debug); //Results contain both internal and external urls - $expectedInternaLinks = [ + $expectedInternal = [ 'http://localhost', 'http://localhost/pages/first_page', 'http://localhost/favicon.ico', @@ -384,11 +384,11 @@ public function testScanFromTests() 'http://localhost/pages/redirect', 'http://localhost/pages/sameredirect', ]; - $expectedExternalLinks = ['http://google.it']; + $expectedExternal = ['http://google.it']; $internalLinks = $LinkScanner->ResultScan->match(['external' => false])->extract('url'); $externalLinks = $LinkScanner->ResultScan->match(['external' => true])->extract('url'); - $this->assertEquals($expectedInternaLinks, $internalLinks->toList()); - $this->assertEquals($expectedExternalLinks, $externalLinks->toList()); + $this->assertEquals($expectedInternal, $internalLinks->toList()); + $this->assertEquals($expectedExternal, $externalLinks->toList()); $this->debug = []; @@ -419,13 +419,13 @@ public function testScanFromTests() $LinkScanner->setConfig('followRedirects', true)->scan(); $this->assertEquals($expectedDebug, $this->debug); - array_pop($expectedInternaLinks); - array_pop($expectedInternaLinks); - $expectedInternaLinks[] = 'http://localhost/pages/third_page'; + array_pop($expectedInternal); + array_pop($expectedInternal); + $expectedInternal[] = 'http://localhost/pages/third_page'; $internalLinks = $LinkScanner->ResultScan->match(['external' => false])->extract('url'); $externalLinks = $LinkScanner->ResultScan->match(['external' => true])->extract('url'); - $this->assertEquals($expectedInternaLinks, $internalLinks->toList()); - $this->assertEquals($expectedExternalLinks, $externalLinks->toList()); + $this->assertEquals($expectedInternal, $internalLinks->toList()); + $this->assertEquals($expectedExternal, $externalLinks->toList()); $LinkScanner = $this->getLinkScannerClientReturnsFromTests($params); $LinkScanner->setConfig('maxDepth', 1)->scan(); @@ -459,6 +459,6 @@ public function testScanResponseNotOk() $EventManager = $this->getEventManager($LinkScanner); $LinkScanner->scan(); - $this->assertEventFired('LinkScanner.' . 'responseNotOk', $EventManager); + $this->assertEventFired('LinkScanner.responseNotOk', $EventManager); } } From e995bb988517fbf8bbfdece9edb021b4e28dc4ea Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 10 Sep 2019 16:40:49 +0200 Subject: [PATCH 08/13] added badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 3deda2c..67d8212 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![Build Status](https://api.travis-ci.org/mirko-pagliai/cakephp-link-scanner.svg?branch=master)](https://travis-ci.org/mirko-pagliai/cakephp-link-scanner) [![Build status](https://ci.appveyor.com/api/projects/status/hqk7fxtad6r75wk3?svg=true)](https://ci.appveyor.com/project/mirko-pagliai/cakephp-link-scanner) [![codecov](https://codecov.io/gh/mirko-pagliai/cakephp-link-scanner/branch/master/graph/badge.svg)](https://codecov.io/gh/mirko-pagliai/cakephp-link-scanner) +[![CodeFactor](https://www.codefactor.io/repository/github/mirko-pagliai/cakephp-link-scanner/badge/cakephp4)](https://www.codefactor.io/repository/github/mirko-pagliai/cakephp-link-scanner/overview/cakephp4) *LinkScanner* is a CakePHP plugin for recursively scanning links: starting from a full base url, it performs GET requests, checks the status codes, inspects the From 4170023826d554e48c18f742087bd70bac340b16 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 10 Sep 2019 16:41:40 +0200 Subject: [PATCH 09/13] fixed for sniffer --- tests/TestCase/Command/LinkScannerCommandTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/TestCase/Command/LinkScannerCommandTest.php b/tests/TestCase/Command/LinkScannerCommandTest.php index d6de300..046065a 100644 --- a/tests/TestCase/Command/LinkScannerCommandTest.php +++ b/tests/TestCase/Command/LinkScannerCommandTest.php @@ -111,6 +111,7 @@ public function testScan() $this->Command->run(['--verbose'], $this->io); $this->assertErrorContains('404'); } + /** * Test for `scan()` method, with cache enabled * @test From fadb646010476d77441f5f314f330190ac8e7b43 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 10 Sep 2019 16:48:15 +0200 Subject: [PATCH 10/13] some fixes --- src/Event/LinkScannerCommandEventListener.php | 11 ++++------- .../TestCase/Command/LinkScannerCommandTest.php | 6 +++--- tests/TestCase/Utility/LinkScannerTest.php | 17 ++++++----------- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/src/Event/LinkScannerCommandEventListener.php b/src/Event/LinkScannerCommandEventListener.php index 3f00f24..5eeefb2 100644 --- a/src/Event/LinkScannerCommandEventListener.php +++ b/src/Event/LinkScannerCommandEventListener.php @@ -216,15 +216,12 @@ public function scanStarted(Event $event, $startTime, $fullBaseUrl) $this->io->hr(); $cache = Cache::getConfig('LinkScanner'); + list($method, $message) = ['info', __d('link-scanner', 'The cache is disabled')]; if (!$this->args->getOption('no-cache') && Cache::enabled() && !empty($cache['duration'])) { - $this->io->success(__d( - 'link-scanner', - 'The cache is enabled and its duration is `{0}`', - $cache['duration'] - )); - } else { - $this->io->info(__d('link-scanner', 'The cache is disabled')); + $method = 'success'; + $message = __d('link-scanner', 'The cache is enabled and its duration is `{0}`', $cache['duration']); } + call_user_func([$this->io, $method], $message); $message = __d('link-scanner', 'Force mode is not enabled'); if ($this->args->getOption('force')) { diff --git a/tests/TestCase/Command/LinkScannerCommandTest.php b/tests/TestCase/Command/LinkScannerCommandTest.php index 046065a..cfdf0cf 100644 --- a/tests/TestCase/Command/LinkScannerCommandTest.php +++ b/tests/TestCase/Command/LinkScannerCommandTest.php @@ -193,12 +193,12 @@ public function testScanParams() $expectedConfig['fullBaseUrl'] = $this->fullBaseUrl; $this->assertEquals($expectedConfig, $this->LinkScanner->getConfig()); - $lineDifferentFullBaseUrl = function ($line) { + $differentLines = function ($line) { $pattern = sprintf('/^Checking https?:\/\/%s/', preg_quote(get_hostname_from_url($this->fullBaseUrl))); return substr($line, 0, strlen('Checking')) === 'Checking' && !preg_match($pattern, $line); }; - $this->assertEmpty(array_filter($this->_out->messages(), $lineDifferentFullBaseUrl)); + $this->assertEmpty(array_filter($this->_out->messages(), $differentLines)); $this->assertOutputContains('Scanning of external links is not enabled'); //Re-enables external links @@ -207,7 +207,7 @@ public function testScanParams() $this->Command->run($params, $this->io); $expectedConfig['externalLinks'] = true; $this->assertEquals($expectedConfig, $this->LinkScanner->getConfig()); - $this->assertNotEmpty(array_filter($this->_out->messages(), $lineDifferentFullBaseUrl)); + $this->assertNotEmpty(array_filter($this->_out->messages(), $differentLines)); foreach ([ 'example' => $this->LinkScanner->getConfig('target') . DS . 'example', diff --git a/tests/TestCase/Utility/LinkScannerTest.php b/tests/TestCase/Utility/LinkScannerTest.php index e64a785..a45b305 100644 --- a/tests/TestCase/Utility/LinkScannerTest.php +++ b/tests/TestCase/Utility/LinkScannerTest.php @@ -221,13 +221,13 @@ public function testImport() //Gets properties from both client, fixes properties of the `Client` // instances and performs the comparison - $expectedClientProperties = $this->getProperties($this->LinkScanner->Client); - $resultClientProperties = $this->getProperties($result->Client); + $expectedProperties = $this->getProperties($this->LinkScanner->Client); + $resultProperties = $this->getProperties($result->Client); foreach (['_adapter', '__phpunit_invocationMocker', '__phpunit_originalObject', '__phpunit_configurable'] as $key) { - unset($expectedClientProperties[$key], $resultClientProperties[$key]); + unset($expectedProperties[$key], $resultProperties[$key]); } - $expectedProperties = ['Client' => $expectedClientProperties] + $this->getProperties($this->LinkScanner); - $resultProperties = ['Client' => $resultClientProperties] + $this->getProperties($result); + $expectedProperties = ['Client' => $expectedProperties] + $this->getProperties($this->LinkScanner); + $resultProperties = ['Client' => $resultProperties] + $this->getProperties($result); $this->assertEquals($expectedProperties, $resultProperties); //With a no existing file @@ -302,12 +302,7 @@ public function testScan() $hostname = get_hostname_from_url($this->fullBaseUrl); foreach ($LinkScanner->ResultScan as $item) { - if (!$item->external) { - $this->assertRegexp(sprintf('/^https?:\/\/%s/', preg_quote($hostname)), $item->url); - } else { - $this->assertTextStartsNotWith('http://' . $hostname, $item->url); - $this->assertTextStartsNotWith('https://' . $hostname, $item->url); - } + $this->assertRegexp(sprintf('/^https?:\/\/%s/', preg_quote($hostname)), $item->url); $this->assertContains($item->code, [200, 500]); $this->assertStringStartsWith('text/html', $item->type); } From 69ce94271fc145b95c90e8b673582bb3b2093eb2 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Tue, 10 Sep 2019 17:21:08 +0200 Subject: [PATCH 11/13] fixed --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a7acee8..a7b9a03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,6 +33,7 @@ install: - composer show -i script: + - rm tests/examples/responses/* - if [[ $PHPCS != '1' && $COVERAGE != '1' ]]; then vendor/bin/phpunit; fi - if [[ $PHPCS = 1 ]]; then vendor/bin/phpcs --standard=phpcs.xml.dist; fi - if [[ $COVERAGE = 1 ]]; then vendor/bin/phpunit --coverage-clover=clover.xml; fi From 4276f7365bd70c4edfadacba08f2bf5fa8b88998 Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Wed, 11 Sep 2019 12:13:21 +0200 Subject: [PATCH 12/13] fixed --- tests/TestCase/Utility/LinkScannerTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/TestCase/Utility/LinkScannerTest.php b/tests/TestCase/Utility/LinkScannerTest.php index a45b305..628d18d 100644 --- a/tests/TestCase/Utility/LinkScannerTest.php +++ b/tests/TestCase/Utility/LinkScannerTest.php @@ -144,8 +144,6 @@ public function testGetResponse() if ($response->isOk()) { $this->assertNotEmpty($responseFromCache); $this->assertInstanceof(Response::class, $responseFromCache); - } else { - $this->assertEmpty($responseFromCache); } } From 47f5d6e5dc92d9bbfc60ab87a01518fdec767ffe Mon Sep 17 00:00:00 2001 From: mirko-pagliai Date: Wed, 11 Sep 2019 12:19:48 +0200 Subject: [PATCH 13/13] updated --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6782d0f..61382ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ ## 1.0 branch ### 1.0.7 * added tests for lower dependencies; -* no longer uses `File` and `Folder` classes. +* no longer uses `File` and `Folder` classes; +* little fixes. ### 1.0.6 * `LinkScanner::import()` can no longer be called statically;