diff --git a/.travis.yml b/.travis.yml index a7b9a03..adffa71 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,6 @@ language: php php: - - 5.6 - - 7.0 - - 7.1 - 7.2 - 7.3 @@ -11,19 +8,13 @@ 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 + - php: 7.2 env: PHPCS=1 - - php: 7.0 + - php: 7.2 env: COVERAGE=1 install: diff --git a/CHANGELOG.md b/CHANGELOG.md index e5f3cff..207be97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # 1.x branch +## 1.1 branch +### 1.1.0 +* updated for `cakephp` 4 and `phpunit` 8. + ## 1.0 branch ### 1.0.8 * APIs are now generated by `phpDocumentor` and no longer by` apigen`. diff --git a/README.md b/README.md index 67d8212..d212238 100644 --- a/README.md +++ b/README.md @@ -4,7 +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) +[![CodeFactor](https://www.codefactor.io/repository/github/mirko-pagliai/cakephp-link-scanner/badge)](https://www.codefactor.io/repository/github/mirko-pagliai/cakephp-link-scanner) *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 @@ -13,7 +13,7 @@ response bodies and, if it finds other links, it continues recursively scanning. ![gif of terminal](https://github.com/mirko-pagliai/cakephp-link-scanner/raw/master/docs/tty.gif) Did you like this plugin? Its development requires a lot of time for me. -Please consider the possibility of making [a donation](//paypal.me/mirkopagliai): +Please consider the possibility of making [a donation](//paypal.me/mirkopagliai): even a coffee is enough! Thank you. [![Make a donation](https://www.paypalobjects.com/webstatic/mktg/logo-center/logo_paypal_carte.jpg)](//paypal.me/mirkopagliai) @@ -24,10 +24,19 @@ You can install the plugin via composer: $ composer require --prefer-dist mirko-pagliai/cakephp-link-scanner ``` -**NOTE: the latest version available requires at least CakePHP 3.7.1**. - +**NOTE: the latest version available requires at least CakePHP 4**. + +Instead, the [cakephp3](//github.com/mirko-pagliai/cakephp-link-scanner/tree/cakephp3) +branch is compatible with all previous versions of CakePHP from version 3.7.1. +This branch coincides with the current version of *cakephp-link-scanner*. + +In this case, you can install the package as well: + +```bash +$ composer require --prefer-dist mirko-pagliai/cakephp-link-scanner:dev-cakephp3 + Then you have to load the plugin. For more information on how to load the plugin, -please refer to the [Cookbook](//book.cakephp.org/3.0/en/plugins.html#loading-a-plugin). +please refer to the [Cookbook](//book.cakephp.org/4.0/en/plugins.html#loading-a-plugin). Simply, you can execute the shell command to enable the plugin: ```bash @@ -37,7 +46,7 @@ This would update your application's bootstrap method. ## Configuration It's not essential, but it may be useful to set the `App.fullBaseUrl` value -correctly [refer to the Cookbook](//book.cakephp.org/3.0/en/development/configuration.html#general-configuration), +correctly [refer to the Cookbook](//book.cakephp.org/4.0/en/development/configuration.html#general-configuration), especially if you plan to use the plugin mainly on your app, so as not to have to indicate the full base url which to start the scan every time. @@ -54,6 +63,6 @@ In addition, you can refer to our [API](//mirko-pagliai.github.io/cakephp-link-s * allow to export results as html and/or xml. ## Versioning -For transparency and insight into our release cycle and to maintain backward -compatibility, *Assets* will be maintained under the +For transparency and insight into our release cycle and to maintain backward +compatibility, *Assets* will be maintained under the [Semantic Versioning guidelines](//semver.org). diff --git a/composer.json b/composer.json index 38b6e0b..5f7580b 100644 --- a/composer.json +++ b/composer.json @@ -5,18 +5,18 @@ "type": "cakephp-plugin", "license": "MIT", "authors": [{ - "name": "Mirko Pagliai", - "email": "mirko.pagliai@gmail.com" - }], + "name": "Mirko Pagliai", + "email": "mirko.pagliai@gmail.com" + }], "require": { - "php": ">=5.5.9", - "cakephp/cakephp": "^3.7.1", - "mirko-pagliai/me-tools": "^2.18.9", - "mirko-pagliai/php-tools": "^1.2.6" + "php": ">=7.2", + "cakephp/cakephp": "^4.0", + "mirko-pagliai/me-tools": "^2.19", + "mirko-pagliai/php-tools": "^1.3" }, "require-dev": { - "cakephp/cakephp-codesniffer": "^3.0", - "phpunit/phpunit": "^5.7.14|^6.0" + "cakephp/cakephp-codesniffer": "^4.0", + "phpunit/phpunit": "^8.0" }, "autoload": { "psr-4": { diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 5cc1928..2bb84c4 100644 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -4,4 +4,11 @@ . + + + /tests/test_app/TestApp/Template/Error/error500.php + + + 0 + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 4428ddc..3e890ad 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -3,7 +3,6 @@ colors="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" bootstrap="./tests/bootstrap.php" > diff --git a/src/Command/LinkScannerCommand.php b/src/Command/LinkScannerCommand.php index 0d21c1d..8754d78 100644 --- a/src/Command/LinkScannerCommand.php +++ b/src/Command/LinkScannerCommand.php @@ -1,4 +1,5 @@ LinkScanner = $this->LinkScanner ?: new LinkScanner(); } @@ -49,7 +50,7 @@ public function initialize() * @see LinkScannerCommandEventListener::implementedEvents() * @uses $LinkScanner */ - public function execute(Arguments $args, ConsoleIo $io) + public function execute(Arguments $args, ConsoleIo $io): ?int { try { //Will trigger events provided by `LinkScannerCommandEventListener` @@ -96,7 +97,7 @@ public function execute(Arguments $args, ConsoleIo $io) * @return \Cake\Console\ConsoleOptionParser The built parser * @uses $LinkScanner */ - protected function buildOptionParser(ConsoleOptionParser $parser) + protected function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionParser { $parser->setDescription(__d('link-scanner', 'Performs a complete scan')); diff --git a/src/Event/LinkScannerCommandEventListener.php b/src/Event/LinkScannerCommandEventListener.php index 550c7be..607c355 100644 --- a/src/Event/LinkScannerCommandEventListener.php +++ b/src/Event/LinkScannerCommandEventListener.php @@ -1,4 +1,5 @@ args->getOption('verbose')) { return true; @@ -104,7 +105,7 @@ public function afterScanUrl(Event $event, Response $response) * @return bool * @uses $io */ - public function beforeScanUrl(Event $event, $url) + public function beforeScanUrl(Event $event, string $url): bool { $this->io->verbose(__d('link-scanner', 'Checking {0} ...', $url), 0); @@ -118,7 +119,7 @@ public function beforeScanUrl(Event $event, $url) * @return bool * @uses $io */ - public function foundLinkToBeScanned(Event $event, $link) + public function foundLinkToBeScanned(Event $event, string $link): bool { $this->io->verbose(__d('link-scanner', 'Link found: {0}', $link)); @@ -132,7 +133,7 @@ public function foundLinkToBeScanned(Event $event, $link) * @return bool * @uses $io */ - public function foundRedirect(Event $event, $url) + public function foundRedirect(Event $event, string $url): bool { $this->io->verbose(__d('link-scanner', 'Redirect found: {0}', $url)); @@ -146,7 +147,7 @@ public function foundRedirect(Event $event, $url) * @return bool * @uses $io */ - public function resultsExported(Event $event, $filename) + public function resultsExported(Event $event, string $filename): bool { $this->io->success(__d('link-scanner', 'Results have been exported to {0}', $filename)); @@ -157,10 +158,11 @@ public function resultsExported(Event $event, $filename) * `LinkScanner.resultsImported` event * @param \Cake\Event\Event $event An `Event` instance * @param string $filename Filename - * @return void + * @return bool */ - public function resultsImported(Event $event, $filename) + public function resultsImported(Event $event, string $filename): bool { + return true; } /** @@ -173,7 +175,7 @@ public function resultsImported(Event $event, $filename) * @uses $args * @uses $io */ - public function scanCompleted(Event $event, $startTime, $endTime, ResultScan $ResultScan) + public function scanCompleted(Event $event, int $startTime, int $endTime, ResultScan $ResultScan): bool { if ($this->args->getOption('verbose')) { $this->io->hr(); @@ -202,7 +204,7 @@ public function scanCompleted(Event $event, $startTime, $endTime, ResultScan $Re * @uses $args * @uses $io */ - public function scanStarted(Event $event, $startTime, $fullBaseUrl) + public function scanStarted(Event $event, int $startTime, string $fullBaseUrl): bool { if ($this->args->getOption('verbose')) { $this->io->hr(); @@ -218,7 +220,7 @@ 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')]; + [$method, $message] = ['info', __d('link-scanner', 'The cache is disabled')]; if (!$this->args->getOption('no-cache') && Cache::enabled() && !empty($cache['duration'])) { $method = 'success'; $message = __d('link-scanner', 'The cache is enabled and its duration is `{0}`', $cache['duration']); diff --git a/src/Event/LinkScannerEventListenerInterface.php b/src/Event/LinkScannerEventListenerInterface.php index 826af24..7bcc031 100644 --- a/src/Event/LinkScannerEventListenerInterface.php +++ b/src/Event/LinkScannerEventListenerInterface.php @@ -1,4 +1,5 @@ toArray() : $items; @@ -39,10 +41,10 @@ protected function parseItems($items) /** * Constructor - * @param array|\Traversable $items Items + * @param iterable $items Items * @uses parseItems() */ - public function __construct($items = []) + public function __construct(iterable $items = []) { parent::__construct($this->parseItems($items)); } @@ -52,11 +54,11 @@ public function __construct($items = []) * * Returns a new `ResultScan` instance as the result of concatenating the * list of elements in this collection with the passed list of elements - * @param array|\Traversable $items Items + * @param iterable $items Items * @return \Cake\Collection\CollectionInterface * @uses parseItems() */ - public function append($items) + public function append($items): CollectionInterface { return new ResultScan(array_merge($this->buffered()->toArray(), $this->parseItems($items))); } @@ -66,11 +68,11 @@ public function append($items) * * Returns a new `ResultScan` instance as the result of concatenating the * passed list of elements with the list of elements in this collection - * @param array|\Traversable $items Items + * @param iterable $items Items * @return \Cake\Collection\CollectionInterface * @uses parseItems() */ - public function prepend($items) + public function prepend($items): CollectionInterface { return new ResultScan(array_merge($this->parseItems($items), $this->buffered()->toArray())); } diff --git a/src/ScanEntity.php b/src/ScanEntity.php index 2115777..949c040 100644 --- a/src/ScanEntity.php +++ b/src/ScanEntity.php @@ -1,4 +1,5 @@ getMockBuilder(Client::class) ->setMethods(['get']) @@ -42,7 +43,7 @@ protected function getClientReturnsFromTests() //It also analyzes the url of the test application and transforms them into parameter arrays $Client->method('get')->will($this->returnCallback(function ($url) { if (is_string($url) && preg_match('/^http:\/\/localhost\/?(pages\/(.+))?$/', $url, $matches)) { - $url = ['controller' => 'Pages', 'action' => 'display', empty($matches[2]) ? 'home' : $matches[2]]; + $url = ['controller' => 'Pages', 'action' => 'display', $matches[2] ?? 'home']; } call_user_func([$this, 'get'], $url); @@ -73,7 +74,7 @@ protected function getClientReturnsFromTests() * @return \LinkScanner\Utility\LinkScanner|\PHPUnit_Framework_MockObject_MockObject * @uses getClientReturnsFromTests() */ - protected function getLinkScannerClientReturnsFromTests($fullBaseUrl = null) + protected function getLinkScannerClientReturnsFromTests($fullBaseUrl = null): object { $fullBaseUrl = $fullBaseUrl ?: Configure::read('App.fullBaseUrl', 'http://localhost'); $fullBaseUrl = is_string($fullBaseUrl) ? $fullBaseUrl : Router::url($fullBaseUrl, true); diff --git a/src/TestSuite/TestCase.php b/src/TestSuite/TestCase.php index 69d0b56..6e1deda 100644 --- a/src/TestSuite/TestCase.php +++ b/src/TestSuite/TestCase.php @@ -1,4 +1,5 @@ getEventList()->hasEvent($name); @@ -57,10 +59,10 @@ public function assertEventNotFired($name, $eventManager = null) /** * Returns a stub of `Client`, where the `get()` method always returns a * response with error (404 status code) - * @return \Cake\Http\Client + * @return \Cake\Http\Client|\PHPUnit_Framework_MockObject_MockObject * @uses getResponseWithBody() */ - protected function getClientReturnsErrorResponse() + protected function getClientReturnsErrorResponse(): object { $Client = $this->getMockBuilder(Client::class) ->setMethods(['get']) @@ -68,7 +70,7 @@ protected function getClientReturnsErrorResponse() //This allows the `Client` instance to use the `IntegrationTestCase::get()` method //It also analyzes the url of the test application and transforms them into parameter arrays - $Client->method('get')->will($this->returnValue($this->getResponseWithBody(null)->withStatus(404))); + $Client->method('get')->will($this->returnValue($this->getResponseWithBody('')->withStatus(404))); return $Client; } @@ -76,10 +78,10 @@ protected function getClientReturnsErrorResponse() /** * Returns a stub of `Client`, where the `get()` method returns a sample * response which is read from `examples/responses` files - * @return \Cake\Http\Client + * @return \Cake\Http\Client|\PHPUnit_Framework_MockObject_MockObject * @uses getResponseWithBody() */ - protected function getClientReturnsSampleResponse() + protected function getClientReturnsSampleResponse(): object { $Client = $this->getMockBuilder(Client::class) ->setMethods(['get']) @@ -113,7 +115,7 @@ protected function getClientReturnsSampleResponse() * @param \LinkScanner\Utility\LinkScanner|null $LinkScanner `LinkScanner` instance or `null` * @return \Cake\Event\EventManager */ - protected function getEventManager(LinkScanner $LinkScanner = null) + protected function getEventManager(?LinkScanner $LinkScanner = null): EventManager { $LinkScanner = $LinkScanner ?: $this->LinkScanner; $eventManager = $LinkScanner->getEventManager(); @@ -134,7 +136,7 @@ protected function getEventManager(LinkScanner $LinkScanner = null) * `null` to create a new instance * @return \Cake\Http\Client\Response */ - protected function getResponseWithBody($body, Response $response = null) + protected function getResponseWithBody(string $body, ?Response $response = null): Response { $response = $response ?: new Response(); $stream = new Stream('php://memory', 'wb+'); diff --git a/src/Utility/LinkScanner.php b/src/Utility/LinkScanner.php index f90ddae..d8fd0bf 100644 --- a/src/Utility/LinkScanner.php +++ b/src/Utility/LinkScanner.php @@ -1,4 +1,5 @@ Client = $Client ?: new Client(['redirect' => true]); $this->ResultScan = $ResultScan ?: new ResultScan(); @@ -126,7 +127,7 @@ public function __construct($Client = null, $ResultScan = null) * @param string $name Property name * @return mixed */ - public function __get($name) + public function __get(string $name) { return $this->$name; } @@ -137,7 +138,7 @@ public function __get($name) * @throws \RuntimeException * @uses $lockFile */ - protected function _createLockFile() + protected function _createLockFile(): bool { is_true_or_fail(!$this->getConfig('lockFile') || !file_exists($this->lockFile), __d( 'link-scanner', @@ -154,7 +155,7 @@ protected function _createLockFile() * @return string * @since 1.0.7 */ - protected function _getAbsolutePath($filename) + protected function _getAbsolutePath(string $filename): string { $isAbsolute = (new Filesystem())->isAbsolutePath($filename); @@ -171,7 +172,7 @@ protected function _getAbsolutePath($filename) * @uses $alreadyScanned * @uses $fullBaseUrl */ - protected function _getResponse($url) + protected function _getResponse(string $url): Response { $this->alreadyScanned[] = $url; $cacheKey = sprintf('response_%s', md5(serialize($url))); @@ -179,7 +180,7 @@ protected function _getResponse($url) $response = $this->getConfig('cache') ? Cache::read($cacheKey, 'LinkScanner') : null; if ($response && is_array($response)) { - list($response, $body) = $response; + [$response, $body] = $response; $stream = new Stream('php://memory', 'wb+'); $stream->write($body); @@ -223,7 +224,7 @@ protected function _getResponse($url) * @uses $currentDepth * @uses $hostname */ - protected function _recursiveScan($url, $referer = null) + protected function _recursiveScan(string $url, ?string $referer = null): void { $response = $this->_singleScan($url, $referer); @@ -268,13 +269,13 @@ protected function _recursiveScan($url, $referer = null) * - `LinkScanner.foundRedirect`: will be triggered if a redirect is found. * @param string $url Url to scan * @param string|null $referer Referer of this url - * @return \LinkScanner\Http\Client\ScanResponse|null + * @return \Cake\Http\Client\Response|null * @uses _getResponse() * @uses canBeScanned() * @uses $ResultScan * @uses $hostname */ - protected function _singleScan($url, $referer = null) + protected function _singleScan(string $url, ?string $referer = null): ?Response { $url = clean_url($url, true, true); if (!$this->canBeScanned($url)) { @@ -319,7 +320,7 @@ protected function _singleScan($url, $referer = null) * @uses $alreadyScanned * @uses $hostname */ - protected function canBeScanned($url) + protected function canBeScanned(string $url): bool { if (!is_url($url) || in_array($url, $this->alreadyScanned) || (!$this->getConfig('externalLinks') && is_external_url($url, $this->hostname))) { @@ -340,7 +341,7 @@ protected function canBeScanned($url) * @return string * @uses $Client */ - public function serialize() + public function serialize(): string { //Unsets the event class and event manager. For the `Client` instance, // it takes only configuration and cookies @@ -357,7 +358,7 @@ public function serialize() * @return void * @uses $Client */ - public function unserialize($serialized) + public function unserialize($serialized): void { //Resets the event list and the Client instance $properties = unserialize($serialized); @@ -388,7 +389,7 @@ public function unserialize($serialized) * @uses $hostname * @uses $startTime */ - public function export($filename = null) + public function export(?string $filename = null): string { is_true_or_fail( !$this->ResultScan->isEmpty(), @@ -412,11 +413,11 @@ public function export($filename = null) * - `LinkScanner.resultsImported`: will be triggered when the results have * been exported. * @param string $filename Filename from which to import - * @return \LinkScanner\Utility\LinkScanner + * @return $this * @uses _getAbsolutePath() * @throws \RuntimeException */ - public function import($filename) + public function import(string $filename) { $filename = $this->_getAbsolutePath($filename); @@ -472,7 +473,7 @@ public function scan() $this->_createLockFile(); $this->startTime = time(); - $maxNestingLevel = ini_set('xdebug.max_nesting_level', -1); + $maxNestingLevel = ini_set('xdebug.max_nesting_level', '-1'); try { $this->dispatchEvent('LinkScanner.scanStarted', [$this->startTime, $fullBaseUrl]); @@ -480,7 +481,7 @@ public function scan() $this->endTime = time(); $this->dispatchEvent('LinkScanner.scanCompleted', [$this->startTime, $this->endTime, $this->ResultScan]); } finally { - ini_set('xdebug.max_nesting_level', $maxNestingLevel); + ini_set('xdebug.max_nesting_level', (string)$maxNestingLevel); @unlink($this->lockFile); } diff --git a/tests/TestCase/Command/LinkScannerCommandTest.php b/tests/TestCase/Command/LinkScannerCommandTest.php index cfdf0cf..c8a31dd 100644 --- a/tests/TestCase/Command/LinkScannerCommandTest.php +++ b/tests/TestCase/Command/LinkScannerCommandTest.php @@ -1,4 +1,5 @@ assertOutputRegExp('/Timeout in seconds for GET requests: \d+/'); //Moves to final lines - $messages = $this->_out->messages(); + $messages = array_values(array_filter($this->_out->messages())); $count = count($messages); while (key($messages) !== $count - 5) { next($messages); diff --git a/tests/TestCase/ResultScanTest.php b/tests/TestCase/ResultScanTest.php index 3ac0ec0..1016b56 100644 --- a/tests/TestCase/ResultScanTest.php +++ b/tests/TestCase/ResultScanTest.php @@ -1,4 +1,5 @@ $expectedValue) { $this->ScanEntity->set('code', $code); - $this->assertEquals($expectedValue, $this->ScanEntity->isOk()); + $this->assertEquals($expectedValue, $this->ScanEntity->isSuccess()); } $statusCodes = [ 200 => false, diff --git a/tests/TestCase/Utility/LinkScannerTest.php b/tests/TestCase/Utility/LinkScannerTest.php index 628d18d..e42e514 100644 --- a/tests/TestCase/Utility/LinkScannerTest.php +++ b/tests/TestCase/Utility/LinkScannerTest.php @@ -1,4 +1,5 @@ write($body); @@ -130,17 +131,15 @@ public function testGetResponse() $this->LinkScanner->setConfig('cache', true); foreach ([ - 'nolinks' => 200, - 'home' => 200, - 'noexisting' => 500, - ] as $pageName => $expectedStatusCode) { - $params = ['controller' => 'Pages', 'action' => 'display', $pageName]; - - $response = $getResponseMethod($params); + 'http://localhost/pages/nolinks' => 200, + 'http://localhost/pages/home' => 200, + 'http://localhost/pages/noexisting' => 500, + ] as $url => $expectedStatusCode) { + $response = $getResponseMethod($url); $this->assertEquals($expectedStatusCode, $response->getStatusCode()); $this->assertStringStartsWith('text/html', $response->getHeaderLine('content-type')); - $responseFromCache = $getResponseFromCache($params); + $responseFromCache = $getResponseFromCache($url); if ($response->isOk()) { $this->assertNotEmpty($responseFromCache); $this->assertInstanceof(Response::class, $responseFromCache); @@ -360,8 +359,7 @@ public function testScanFromTests() 'Found link: http://localhost/pages/sameredirect', 'Scanning http://localhost/pages/sameredirect', ]; - $params = ['controller' => 'Pages', 'action' => 'display', 'home']; - $LinkScanner = $this->getLinkScannerClientReturnsFromTests($params); + $LinkScanner = $this->getLinkScannerClientReturnsFromTests(); $LinkScanner->scan(); $this->assertEquals($expectedDebug, $this->debug); @@ -408,7 +406,7 @@ public function testScanFromTests() 'Found link: http://localhost/pages/sameredirect', 'Scanning http://localhost/pages/sameredirect', ]; - $LinkScanner = $this->getLinkScannerClientReturnsFromTests($params); + $LinkScanner = $this->getLinkScannerClientReturnsFromTests(); $LinkScanner->setConfig('followRedirects', true)->scan(); $this->assertEquals($expectedDebug, $this->debug); @@ -420,7 +418,7 @@ public function testScanFromTests() $this->assertEquals($expectedInternal, $internalLinks->toList()); $this->assertEquals($expectedExternal, $externalLinks->toList()); - $LinkScanner = $this->getLinkScannerClientReturnsFromTests($params); + $LinkScanner = $this->getLinkScannerClientReturnsFromTests(); $LinkScanner->setConfig('maxDepth', 1)->scan(); $this->assertCount(1, $LinkScanner->ResultScan); $item = $LinkScanner->ResultScan->first(); @@ -437,7 +435,7 @@ public function testScanFromTests() */ public function testScanNoOtherLinks() { - $LinkScanner = $this->getLinkScannerClientReturnsFromTests(['controller' => 'Pages', 'action' => 'display', 'nolinks']); + $LinkScanner = $this->getLinkScannerClientReturnsFromTests('http://localhost/pages/nolinks'); $this->assertEventNotFired('LinkScanner.foundLinkToBeScanned', $this->getEventManager($LinkScanner->scan())); } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d2e42e4..22b9a22 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,4 +1,5 @@ addPlugin(LinkScanner::class); } @@ -37,10 +39,8 @@ public function bootstrap() * @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to set in your App Class * @return \Cake\Http\MiddlewareQueue */ - public function middleware($middlewareQueue) + public function middleware($middlewareQueue): MiddlewareQueue { - $middlewareQueue->add(new RoutingMiddleware($this)); - - return $middlewareQueue; + return $middlewareQueue->add(new RoutingMiddleware($this)); } } diff --git a/tests/test_app/TestApp/Controller/AppController.php b/tests/test_app/TestApp/Controller/AppController.php index 2f38a4d..34dc990 100644 --- a/tests/test_app/TestApp/Controller/AppController.php +++ b/tests/test_app/TestApp/Controller/AppController.php @@ -1,11 +1,13 @@ viewBuilder()->setLayout(false); + $this->viewBuilder()->disableAutoLayout(); } $count = count($path); diff --git a/tests/test_app/TestApp/Template/Error/error500.php b/tests/test_app/TestApp/Template/Error/error500.php new file mode 100644 index 0000000..826e686 --- /dev/null +++ b/tests/test_app/TestApp/Template/Error/error500.php @@ -0,0 +1,45 @@ +layout = 'error'; + +if (Configure::read('debug')) : + $this->layout = 'dev_error'; + + $this->assign('title', $message); + $this->assign('templateName', 'error500.php'); + + $this->start('file'); + ?> + queryString)) : ?> +

+ SQL Query: + queryString) ?> +

+ + params)) : ?> + SQL Query Params: + params) ?> + + + Error in: + getFile()), $error->getLine()) ?> + + element('auto_table_warning'); + + if (extension_loaded('xdebug')) : + xdebug_print_function_stack(); + endif; + + $this->end(); +endif; +?> +

+

+ : + +

\ No newline at end of file diff --git a/tests/test_app/TestApp/Template/Pages/first_page.ctp b/tests/test_app/TestApp/Template/Pages/first_page.ctp deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_app/TestApp/Template/Pages/first_page.php b/tests/test_app/TestApp/Template/Pages/first_page.php new file mode 100644 index 0000000..a766f11 --- /dev/null +++ b/tests/test_app/TestApp/Template/Pages/first_page.php @@ -0,0 +1,2 @@ +No links here \ No newline at end of file diff --git a/tests/test_app/TestApp/Template/Pages/nolinks.php b/tests/test_app/TestApp/Template/Pages/nolinks.php new file mode 100644 index 0000000..068bea1 --- /dev/null +++ b/tests/test_app/TestApp/Template/Pages/nolinks.php @@ -0,0 +1,4 @@ +No links here'; diff --git a/tests/test_app/TestApp/Template/Pages/second_page.ctp b/tests/test_app/TestApp/Template/Pages/second_page.ctp deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_app/TestApp/Template/Pages/second_page.php b/tests/test_app/TestApp/Template/Pages/second_page.php new file mode 100644 index 0000000..a766f11 --- /dev/null +++ b/tests/test_app/TestApp/Template/Pages/second_page.php @@ -0,0 +1,2 @@ +