diff --git a/.travis.yml b/.travis.yml index afad34b..7964dd8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,13 @@ +sudo: false language: php - php: - 5.5 - 5.6 + - 7 install: - - composer install \ No newline at end of file + - composer install + +script: + - composer cs + - composer test \ No newline at end of file diff --git a/composer.json b/composer.json index 31ab40d..61a7a54 100644 --- a/composer.json +++ b/composer.json @@ -12,11 +12,19 @@ } ], "autoload": { - "psr-0": { - "webignition\\Tests": "tests/", - "": "src/" + "psr-4": { + "webignition\\WebsiteRssFeedFinder\\": "src/", + "webignition\\Tests\\WebsiteRssFeedFinder\\": "tests/" } }, + "scripts": { + "test": "./vendor/bin/phpunit --colors=always", + "cs": "./vendor/bin/phpcs src tests --colors --standard=PSR2", + "ci": [ + "@composer cs", + "@composer test" + ] + }, "require": { "php": ">=5.5.0", "webignition/internet-media-type":">=0.1,<1.0", @@ -25,6 +33,10 @@ "webignition/url":">=1.7.2,<2.0", "webignition/cookie-url-matcher":">=0.1,<1.0" }, + "require-dev": { + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "3.*" + }, "minimum-stability":"dev", "prefer-stable":true } diff --git a/composer.lock b/composer.lock index eaf47fc..6b48f27 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "aa37d5063139465b510b6cc7bfcc5344", + "content-hash": "35c4b9b825c63e536e4f1b6741795a3f", "packages": [ { "name": "doctrine/collections", @@ -904,7 +904,1175 @@ "time": "2013-02-27T03:27:30+00:00" } ], - "packages-dev": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14T21:17:01+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2015-12-27T11:43:31+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0@dev", + "phpdocumentor/type-resolver": "^0.2.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2016-09-30T07:12:33+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.2.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb", + "shasum": "" + }, + "require": { + "php": ">=5.5", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2016-11-25T06:54:22+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/93d39f1f7f9326d746203c7c056f300f7f126073", + "reference": "93d39f1f7f9326d746203c7c056f300f7f126073", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2", + "sebastian/comparator": "^1.1|^2.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8 || ^5.6.5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "autoload": { + "psr-0": { + "Prophecy\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Konstantin Kudryashov", + "email": "ever.zet@gmail.com", + "homepage": "http://everzet.com" + }, + { + "name": "Marcello Duarte", + "email": "marcello.duarte@gmail.com" + } + ], + "description": "Highly opinionated mocking framework for PHP 5.3+", + "homepage": "https://github.com/phpspec/prophecy", + "keywords": [ + "Double", + "Dummy", + "fake", + "mock", + "spy", + "stub" + ], + "time": "2017-03-02T20:05:34+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "^1.3.2", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-10-06T15:47:00+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "reference": "3cc8f69b3028d0f96a9078e6295d86e9bf019be5", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "FilterIterator implementation that filters files based on a list of suffixes.", + "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2016-10-03T07:40:28+00:00" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21T13:50:34+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2017-02-26T11:10:40+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.11", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2017-02-27T10:12:30+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "4.8.35", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/791b1a67c25af50e230f841ee7a9c6eba507dc87", + "reference": "791b1a67c25af50e230f841ee7a9c6eba507dc87", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "^1.3.1", + "phpunit/php-code-coverage": "~2.1", + "phpunit/php-file-iterator": "~1.4", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "^1.0.6", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.2.2", + "sebastian/diff": "~1.2", + "sebastian/environment": "~1.3", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.1|~3.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.8.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", + "keywords": [ + "phpunit", + "testing", + "xunit" + ], + "time": "2017-02-06T05:18:07+00:00" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-10-02T06:51:40+00:00" + }, + { + "name": "sebastian/comparator", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2 || ~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2017-01-29T09:50:25+00:00" + }, + { + "name": "sebastian/diff", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-12-08T07:14:41+00:00" + }, + { + "name": "sebastian/environment", + "version": "1.3.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8 || ^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2016-08-18T05:49:44+00:00" + }, + { + "name": "sebastian/exporter", + "version": "1.2.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", + "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2016-06-17T09:04:28+00:00" + }, + { + "name": "sebastian/global-state", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2015-10-12T03:26:01+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2016-10-03T07:41:43+00:00" + }, + { + "name": "sebastian/version", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-06-21T13:59:46+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "b95ff2c3b122a3ee4b57d149a57d2afce65522c3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b95ff2c3b122a3ee4b57d149a57d2afce65522c3", + "reference": "b95ff2c3b122a3ee4b57d149a57d2afce65522c3", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2017-05-04T00:33:04+00:00" + }, + { + "name": "symfony/yaml", + "version": "v3.2.8", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "acec26fcf7f3031e094e910b94b002fa53d4e4d6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/acec26fcf7f3031e094e910b94b002fa53d4e4d6", + "reference": "acec26fcf7f3031e094e910b94b002fa53d4e4d6", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "require-dev": { + "symfony/console": "~2.8|~3.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2017-05-01T14:55:58+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f", + "reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" + ], + "time": "2016-11-23T20:04:58+00:00" + } + ], "aliases": [], "minimum-stability": "dev", "stability-flags": [], diff --git a/src/Configuration.php b/src/Configuration.php new file mode 100644 index 0000000..16fe54f --- /dev/null +++ b/src/Configuration.php @@ -0,0 +1,98 @@ +cookies = $cookies; + + return $this; + } + + /** + * + * @return array + */ + public function getCookies() + { + return $this->cookies; + } + + /** + * + * @param GuzzleRequest $request + * @return self + */ + public function setBaseRequest(GuzzleRequest $request) + { + $this->baseRequest = $request; + + return $this; + } + + /** + * + * @return GuzzleRequest $request + */ + public function getBaseRequest() + { + if (is_null($this->baseRequest)) { + $client = new GuzzleClient; + $this->baseRequest = $client->get(); + } + + return $this->baseRequest; + } + + /** + * + * @param string $rootUrl + * @return self + */ + public function setRootUrl($rootUrl) + { + $this->rootUrl = new NormalisedUrl($rootUrl); + + return $this; + } + + /** + * + * @return string|null + */ + public function getRootUrl() + { + return $this->rootUrl; + } +} diff --git a/src/WebsiteRssFeedFinder.php b/src/WebsiteRssFeedFinder.php new file mode 100644 index 0000000..d0d8958 --- /dev/null +++ b/src/WebsiteRssFeedFinder.php @@ -0,0 +1,210 @@ +configuration)) { + $this->configuration = new Configuration(); + } + + return $this->configuration; + } + + /** + * + * @return \webignition\WebsiteRssFeedFinder\WebsiteRssFeedFinder + */ + public function reset() + { + $this->feedUrls = array(); + $this->rootWebPage = null; + return $this; + } + + /** + * + * @return array + */ + public function getRssFeedUrls() + { + return $this->getLinkHref('alternate', 'application/rss+xml'); + } + + /** + * + * @return array + */ + public function getAtomFeedUrls() + { + return $this->getLinkHref('alternate', 'application/atom+xml'); + } + + /** + * + * @param string $rel + * @param string $type + * + * @return string[] + */ + private function getLinkHref($rel, $type) + { + if (!isset($this->feedUrls[$rel]) || !isset($this->feedUrls[$rel][$type])) { + if (!$this->findFeedUrls()) { + return null; + } + } + + if (!isset($this->feedUrls[$rel]) || !isset($this->feedUrls[$rel][$type])) { + return null; + } + + return $this->feedUrls[$rel][$type]; + } + + private function findFeedUrls() + { + $rootWebPage = $this->getRootWebPage(); + if ($rootWebPage == false) { + return false; + } + + libxml_use_internal_errors(true); + + $feedUrls = array(); + $supportedFeedTypes = $this->supportedFeedTypes; + try { + $rootWebPage + ->find('link[rel=alternate]') + ->each( + function ($index, \DOMElement $domElement) use (&$feedUrls, $supportedFeedTypes) { + foreach ($supportedFeedTypes as $supportedFeedType) { + if ($domElement->getAttribute('type') == $supportedFeedType) { + if (!isset($feedUrls['alternate'])) { + $feedUrls['alternate'] = array(); + } + + if (!isset($feedUrls['alternate'][$supportedFeedType])) { + $feedUrls['alternate'][$supportedFeedType] = array(); + } + + $hasSupportedFeedType = in_array( + $domElement->getAttribute('href'), + $feedUrls['alternate'][$supportedFeedType] + ); + + if (!$hasSupportedFeedType) { + $feedUrls['alternate'][$supportedFeedType][] = + $domElement->getAttribute('href'); + } + } + } + }); + } catch (ParseException $parseException) { + // Invalid XML + } + + libxml_use_internal_errors(false); + return $this->feedUrls = $feedUrls; + } + + /** + * + * @return WebPage + */ + private function getRootWebPage() + { + if (is_null($this->rootWebPage)) { + $this->rootWebPage = $this->retrieveRootWebPage(); + } + + return $this->rootWebPage; + } + + /** + * + * @return boolean|WebPage + */ + private function retrieveRootWebPage() + { + $request = clone $this->getConfiguration()->getBaseRequest(); + $request->setUrl($this->getConfiguration()->getRootUrl()); + $this->setRequestCookies($request); + + try { + $response = $request->send(); + } catch (RequestException $requestException) { + return false; + } + + try { + $webPage = new WebPage(); + $webPage->setHttpResponse($response); + return $webPage; + } catch (WebResourceException $exception) { + // Invalid content type (is not the URL of a web page) + return false; + } + } + + /** + * + * @param GuzzleRequest $request + */ + private function setRequestCookies(GuzzleRequest $request) + { + if (!is_null($request->getCookies())) { + foreach ($request->getCookies() as $name => $value) { + $request->removeCookie($name); + } + } + + $cookieUrlMatcher = new UrlMatcher(); + + foreach ($this->getConfiguration()->getCookies() as $cookie) { + if ($cookieUrlMatcher->isMatch($cookie, $request->getUrl())) { + $request->addCookie($cookie['name'], $cookie['value']); + } + } + } +} diff --git a/src/webignition/WebsiteRssFeedFinder/Configuration.php b/src/webignition/WebsiteRssFeedFinder/Configuration.php deleted file mode 100644 index cc1ebb8..0000000 --- a/src/webignition/WebsiteRssFeedFinder/Configuration.php +++ /dev/null @@ -1,98 +0,0 @@ -cookies = $cookies; - return $this; - } - - - /** - * - * @return array - */ - public function getCookies() { - return $this->cookies; - } - - - - /** - * - * @param \Guzzle\Http\Message\Request $request - * @return \webignition\WebsiteRssFeedFinder\WebsiteRssFeedFinder - */ - public function setBaseRequest(\Guzzle\Http\Message\Request $request) { - $this->baseRequest = $request; - return $this; - } - - - - /** - * - * @return \Guzzle\Http\Message\Request $request - */ - public function getBaseRequest() { - if (is_null($this->baseRequest)) { - $client = new \Guzzle\Http\Client; - $this->baseRequest = $client->get(); - } - - return $this->baseRequest; - } - - - /** - * - * @param string $rootUrl - * @return \webignition\WebsiteSitemapFinder\WebsiteSitemapFinder - */ - public function setRootUrl($rootUrl) { - $this->rootUrl = new NormalisedUrl($rootUrl); - return $this; - } - - - /** - * - * @return string|null - */ - public function getRootUrl() { - return $this->rootUrl; - } - -} \ No newline at end of file diff --git a/src/webignition/WebsiteRssFeedFinder/WebsiteRssFeedFinder.php b/src/webignition/WebsiteRssFeedFinder/WebsiteRssFeedFinder.php deleted file mode 100644 index 36e8b88..0000000 --- a/src/webignition/WebsiteRssFeedFinder/WebsiteRssFeedFinder.php +++ /dev/null @@ -1,199 +0,0 @@ -configuration)) { - $this->configuration = new \webignition\WebsiteRssFeedFinder\Configuration(); - } - - return $this->configuration; - } - - - /** - * - * @return \webignition\WebsiteRssFeedFinder\WebsiteRssFeedFinder - */ - public function reset() { - $this->feedUrls = array(); - $this->rootWebPage = null; - return $this; - } - - - /** - * - * @return array - */ - public function getRssFeedUrls() { - return $this->getLinkHref('alternate', 'application/rss+xml'); - } - - - /** - * - * @return array - */ - public function getAtomFeedUrls() { - return $this->getLinkHref('alternate', 'application/atom+xml'); - } - - - /** - * - * @param string $rel - * @param string $type - * @return string - */ - private function getLinkHref($rel, $type) { - if (!isset($this->feedUrls[$rel]) || !isset($this->feedUrls[$rel][$type])) { - if (!$this->findFeedUrls()) { - return null; - } - } - - if (!isset($this->feedUrls[$rel]) || !isset($this->feedUrls[$rel][$type])) { - return null; - } - - return $this->feedUrls[$rel][$type]; - } - - - private function findFeedUrls() { - $rootWebPage = $this->getRootWebPage(); - if ($rootWebPage == false) { - return false; - } - - libxml_use_internal_errors(true); - - $feedUrls = array(); - $supportedFeedTypes = $this->supportedFeedTypes; - try { - $rootWebPage->find('link[rel=alternate]')->each(function ($index, \DOMElement $domElement) use (&$feedUrls, $supportedFeedTypes) { - foreach ($supportedFeedTypes as $supportedFeedType) { - if ($domElement->getAttribute('type') == $supportedFeedType) { - if (!isset($feedUrls['alternate'])) { - $feedUrls['alternate'] = array(); - } - - if (!isset($feedUrls['alternate'][$supportedFeedType])) { - $feedUrls['alternate'][$supportedFeedType] = array(); - } - - if (!in_array($domElement->getAttribute('href'), $feedUrls['alternate'][$supportedFeedType])) { - $feedUrls['alternate'][$supportedFeedType][] = $domElement->getAttribute('href'); - } - } - } - }); - } catch (QueryPath\ParseException $parseException) { - // Invalid XML - } - - libxml_use_internal_errors(false); - return $this->feedUrls = $feedUrls; - } - - - /** - * - * @return WebPage - */ - private function getRootWebPage() { - if (is_null($this->rootWebPage)) { - $this->rootWebPage = $this->retrieveRootWebPage(); - } - - return $this->rootWebPage; - } - - - /** - * - * @return boolean|\webignition\WebResource\WebPage\WebPage - */ - private function retrieveRootWebPage() { - $request = clone $this->getConfiguration()->getBaseRequest(); - $request->setUrl($this->getConfiguration()->getRootUrl()); - $this->setRequestCookies($request); - - try { - $response = $request->send(); - } catch (\Guzzle\Http\Exception\RequestException $requestException) { - return false; - } - - try { - $webPage = new WebPage(); - $webPage->setHttpResponse($response); - return $webPage; - } catch (\webignition\WebResource\Exception $exception) { - // Invalid content type (is not the URL of a web page) - return false; - } - } - - - /** - * - * @param \Guzzle\Http\Message\Request $request - */ - private function setRequestCookies(\Guzzle\Http\Message\Request $request) { - if (!is_null($request->getCookies())) { - foreach ($request->getCookies() as $name => $value) { - $request->removeCookie($name); - } - } - - $cookieUrlMatcher = new \webignition\Cookie\UrlMatcher\UrlMatcher(); - - foreach ($this->getConfiguration()->getCookies() as $cookie) { - if ($cookieUrlMatcher->isMatch($cookie, $request->getUrl())) { - $request->addCookie($cookie['name'], $cookie['value']); - } - } - } - -} \ No newline at end of file diff --git a/tests/BaseTest.php b/tests/BaseTest.php new file mode 100644 index 0000000..d6b6734 --- /dev/null +++ b/tests/BaseTest.php @@ -0,0 +1,134 @@ +httpClient)) { + $this->httpClient = new HttpClient(); + $this->httpClient->addSubscriber(new HistoryPlugin()); + } + + return $this->httpClient; + } + + /** + * + * @return HistoryPlugin|null + */ + protected function getHttpHistory() + { + $listenerCollections = $this->getHttpClient()->getEventDispatcher()->getListeners('request.sent'); + + foreach ($listenerCollections as $listener) { + if ($listener[0] instanceof HistoryPlugin) { + return $listener[0]; + } + } + + return null; + } + + protected function setHttpFixtures($fixtures) + { + $plugin = new MockPlugin(); + + foreach ($fixtures as $fixture) { + $plugin->addResponse($fixture); + } + + $this->getHttpClient()->addSubscriber($plugin); + } + + protected function getHttpFixtures($path) + { + $fixtures = array(); + $fixturesDirectory = new \DirectoryIterator($path); + + $fixturePathnames = array(); + + foreach ($fixturesDirectory as $directoryItem) { + if ($directoryItem->isFile()) { + $fixturePathnames[] = $directoryItem->getPathname(); + } + } + + sort($fixturePathnames); + + foreach ($fixturePathnames as $fixturePathname) { + $fixtures[] = Response::fromMessage(file_get_contents($fixturePathname)); + } + + return $fixtures; + } + + /** + * + * @param string $testName + * @return string + */ + protected function getFixturesDataPath($className, $testName = null) + { + $path = __DIR__ . '/fixtures/' . str_replace('\\', DIRECTORY_SEPARATOR, $className); + + if (!is_null($testName)) { + $path .= '/' . $testName; + } + + return $path; + } + + /** + * + * @return WebsiteRssFeedFinder + */ + protected function getFeedFinder() + { + if (is_null($this->feedFinder)) { + $this->feedFinder = new WebsiteRssFeedFinder(); + $this->feedFinder->getConfiguration()->setBaseRequest($this->getHttpClient()->get()); + } + + return $this->feedFinder; + } + + /** + * + * @param array $items Collection of http messages and/or curl exceptions + * @return array + */ + protected function buildHttpFixtureSet($items) + { + $fixtures = array(); + + foreach ($items as $item) { + $fixtures[] = Response::fromMessage($item); + } + + return $fixtures; + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/BaseRequestTest.php b/tests/Configuration/BaseRequestTest.php similarity index 63% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/BaseRequestTest.php rename to tests/Configuration/BaseRequestTest.php index eaebe1f..feee796 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/BaseRequestTest.php +++ b/tests/Configuration/BaseRequestTest.php @@ -2,24 +2,28 @@ namespace webignition\Tests\WebsiteRssFeedFinder\Configuration; -class BaseRequestTest extends ConfigurationTest { - - public function testGetDefaultBaseRequest() { - $this->assertInstanceOf('\Guzzle\Http\Message\Request', $this->configuration->getBaseRequest()); +use Guzzle\Http\Message\Request; + +class BaseRequestTest extends ConfigurationTest +{ + public function testGetDefaultBaseRequest() + { + $this->assertInstanceOf(Request::class, $this->configuration->getBaseRequest()); } - - public function testSetReturnsSelf() { + + public function testSetReturnsSelf() + { $this->assertEquals($this->configuration, $this->configuration->setBaseRequest($this->getHttpClient()->get())); } - - public function testSetGetBaseRequest() { + + public function testSetGetBaseRequest() + { $baseRequest = $this->getHttpClient()->get(); $baseRequest->setAuth('example_user', 'example_password'); - + $this->configuration->setBaseRequest($baseRequest); - + $this->assertEquals('example_user', $this->configuration->getBaseRequest()->getUsername()); $this->assertEquals($baseRequest->getUsername(), $this->configuration->getBaseRequest()->getUsername()); } - -} \ No newline at end of file +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/ConfigurationTest.php b/tests/Configuration/ConfigurationTest.php similarity index 78% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/ConfigurationTest.php rename to tests/Configuration/ConfigurationTest.php index a2e812e..548ceb5 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/ConfigurationTest.php +++ b/tests/Configuration/ConfigurationTest.php @@ -5,20 +5,17 @@ use webignition\WebsiteRssFeedFinder\Configuration; use webignition\Tests\WebsiteRssFeedFinder\BaseTest; - -abstract class ConfigurationTest extends BaseTest { - +abstract class ConfigurationTest extends BaseTest +{ /** * * @var Configuration */ protected $configuration; - - public function setUp() { + protected function setUp() + { parent::setUp(); $this->configuration = new Configuration(); } - - -} \ No newline at end of file +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/CookiesTest.php b/tests/Configuration/CookiesTest.php similarity index 73% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/CookiesTest.php rename to tests/Configuration/CookiesTest.php index 1c04455..41d0b92 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/CookiesTest.php +++ b/tests/Configuration/CookiesTest.php @@ -2,18 +2,20 @@ namespace webignition\Tests\WebsiteRssFeedFinder\Configuration; -class CookiesTest extends ConfigurationTest { - - public function testGetDefaultCookieCollection() { +class CookiesTest extends ConfigurationTest +{ + public function testGetDefaultCookieCollection() + { $this->assertEquals(array(), $this->configuration->getCookies()); } - - - public function testSetReturnsSelf() { + + public function testSetReturnsSelf() + { $this->assertEquals($this->configuration, $this->configuration->setCookies(array())); } - - public function testSetGetCookies() { + + public function testSetGetCookies() + { $cookies = array( array( 'name' => 'name1', @@ -29,10 +31,9 @@ public function testSetGetCookies() { 'secure' => true, 'name' => 'name3', 'value' => 'value3' - ) + ) ); - + $this->assertEquals($cookies, $this->configuration->setCookies($cookies)->getCookies()); - } - -} \ No newline at end of file + } +} diff --git a/tests/Configuration/RootUrlTest.php b/tests/Configuration/RootUrlTest.php new file mode 100644 index 0000000..ec95339 --- /dev/null +++ b/tests/Configuration/RootUrlTest.php @@ -0,0 +1,36 @@ +assertNull($this->configuration->getRootUrl()); + } + + public function testSetReturnsSelf() + { + $this->assertEquals($this->configuration, $this->configuration->setRootUrl(self::ROOT_URL)); + } + + public function testGetReturnsValueSet() + { + $this->assertEquals( + self::ROOT_URL, + (string)$this->configuration->setRootUrl(self::ROOT_URL)->getRootUrl() + ); + } + + public function testGetReturnsNormalizedUrlObject() + { + $this->assertInstanceOf( + NormalisedUrl::class, + $this->configuration->setRootUrl(self::ROOT_URL)->getRootUrl() + ); + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/CookiesTest.php b/tests/Cookies/CookiesTest.php similarity index 71% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/CookiesTest.php rename to tests/Cookies/CookiesTest.php index 3be4543..5dba3be 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/CookiesTest.php +++ b/tests/Cookies/CookiesTest.php @@ -4,96 +4,96 @@ use webignition\Tests\WebsiteRssFeedFinder\BaseTest; -abstract class CookiesTest extends BaseTest { - +abstract class CookiesTest extends BaseTest +{ /** - * + * * @return array */ abstract protected function getCookies(); - + /** * @return string */ abstract protected function getRootUrl(); - + /** - * + * * @return \Guzzle\Http\Message\RequestInterface[] - */ + */ abstract protected function getExpectedRequestsOnWhichCookiesShouldBeSet(); - + /** - * + * * @return \Guzzle\Http\Message\RequestInterface[] - */ - abstract protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet(); - - - public function setUp() { + */ + abstract protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet(); + + public function setUp() + { $this->setHttpFixtures($this->buildHttpFixtureSet(array( 'HTTP/1.0 200' ))); - + $finder = $this->getFeedFinder(); - $finder->getConfiguration()->setRootUrl($this->getRootUrl()); + $finder->getConfiguration()->setRootUrl($this->getRootUrl()); $finder->getConfiguration()->setCookies($this->getCookies()); $finder->getAtomFeedUrls(); } - - - public function testCookiesAreSetOnExpectedRequests() { + + public function testCookiesAreSetOnExpectedRequests() + { foreach ($this->getExpectedRequestsOnWhichCookiesShouldBeSet() as $request) { $this->assertEquals($this->getExpectedCookieValues(), $request->getCookies()); } } - - public function testCookiesAreNotSetOnExpectedRequests() { - foreach ($this->getExpectedRequestsOnWhichCookiesShouldNotBeSet() as $request) { + + public function testCookiesAreNotSetOnExpectedRequests() + { + foreach ($this->getExpectedRequestsOnWhichCookiesShouldNotBeSet() as $request) { $this->assertEquals(array(), $request->getCookies()); } - } - - + } + /** - * + * * @return array */ - private function getExpectedCookieValues() { + private function getExpectedCookieValues() + { $nameValueArray = array(); - + foreach ($this->getCookies() as $cookie) { $nameValueArray[$cookie['name']] = $cookie['value']; } - + return $nameValueArray; - } - - + } + /** - * + * * @return \Guzzle\Http\Message\Request[] */ - protected function getAllSentHttpRequests() { + protected function getAllSentHttpRequests() + { $requests = array(); - + foreach ($this->getHttpHistory()->getAll() as $httpTransaction) { $requests[] = $httpTransaction['request']; } - + return $requests; } - - - protected function getLastHttpRequest() { + + protected function getLastHttpRequest() + { $requests = $this->getAllSentHttpRequests(); return $requests[count($requests) - 1]; } - - protected function getFirstHttpRequest() { + + protected function getFirstHttpRequest() + { $requests = $this->getAllSentHttpRequests(); - return $requests[0]; + return $requests[0]; } - - -} \ No newline at end of file +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Domain/DomainTest.php b/tests/Cookies/Domain/DomainTest.php similarity index 62% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Domain/DomainTest.php rename to tests/Cookies/Domain/DomainTest.php index 981f485..193192c 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Domain/DomainTest.php +++ b/tests/Cookies/Domain/DomainTest.php @@ -4,9 +4,10 @@ use webignition\Tests\WebsiteRssFeedFinder\Cookies\CookiesTest; -abstract class DomainTest extends CookiesTest { - - protected function getRootUrl() { +abstract class DomainTest extends CookiesTest +{ + protected function getRootUrl() + { return 'http://example.com'; - } -} \ No newline at end of file + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Domain/IsMatchTest.php b/tests/Cookies/Domain/IsMatchTest.php similarity index 79% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Domain/IsMatchTest.php rename to tests/Cookies/Domain/IsMatchTest.php index aa821b2..29fba42 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Domain/IsMatchTest.php +++ b/tests/Cookies/Domain/IsMatchTest.php @@ -2,9 +2,10 @@ namespace webignition\Tests\WebsiteRssFeedFinder\Cookies\Domain; -class IsMatchTest extends DomainTest { - - protected function getCookies() { +class IsMatchTest extends DomainTest +{ + protected function getCookies() + { return array( array( 'domain' => '.example.com', @@ -14,11 +15,13 @@ protected function getCookies() { ); } - protected function getExpectedRequestsOnWhichCookiesShouldBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldBeSet() + { return $this->getAllSentHttpRequests(); } - protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() + { return array(); - } -} \ No newline at end of file + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Domain/NotMatchTest.php b/tests/Cookies/Domain/NotMatchTest.php similarity index 79% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Domain/NotMatchTest.php rename to tests/Cookies/Domain/NotMatchTest.php index 7b5c44b..cf3e608 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Domain/NotMatchTest.php +++ b/tests/Cookies/Domain/NotMatchTest.php @@ -2,9 +2,10 @@ namespace webignition\Tests\WebsiteRssFeedFinder\Cookies\Domain; -class NotMatchTest extends DomainTest { - - protected function getCookies() { +class NotMatchTest extends DomainTest +{ + protected function getCookies() + { return array( array( 'domain' => '.foo.example.com', @@ -14,11 +15,13 @@ protected function getCookies() { ); } - protected function getExpectedRequestsOnWhichCookiesShouldBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldBeSet() + { return array(); } - protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() + { return $this->getAllSentHttpRequests(); - } -} \ No newline at end of file + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Path/IsMatchTest.php b/tests/Cookies/Path/IsMatchTest.php similarity index 81% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Path/IsMatchTest.php rename to tests/Cookies/Path/IsMatchTest.php index 5213692..26c9d7e 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Path/IsMatchTest.php +++ b/tests/Cookies/Path/IsMatchTest.php @@ -2,9 +2,10 @@ namespace webignition\Tests\WebsiteRssFeedFinder\Cookies\Path; -class IsMatchTest extends PathTest { - - protected function getCookies() { +class IsMatchTest extends PathTest +{ + protected function getCookies() + { return array( array( 'domain' => '.example.com', @@ -15,11 +16,13 @@ protected function getCookies() { ); } - protected function getExpectedRequestsOnWhichCookiesShouldBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldBeSet() + { return $this->getAllSentHttpRequests(); } - protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() + { return array(); - } -} \ No newline at end of file + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Path/NotMatchTest.php b/tests/Cookies/Path/NotMatchTest.php similarity index 80% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Path/NotMatchTest.php rename to tests/Cookies/Path/NotMatchTest.php index b675cc2..84cf4c3 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Path/NotMatchTest.php +++ b/tests/Cookies/Path/NotMatchTest.php @@ -2,9 +2,10 @@ namespace webignition\Tests\WebsiteRssFeedFinder\Cookies\Path; -class NotMatchTest extends PathTest { - - protected function getCookies() { +class NotMatchTest extends PathTest +{ + protected function getCookies() + { return array( array( 'domain' => '.example.com', @@ -15,11 +16,13 @@ protected function getCookies() { ); } - protected function getExpectedRequestsOnWhichCookiesShouldBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldBeSet() + { return array(); } - protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() + { return $this->getAllSentHttpRequests(); - } -} \ No newline at end of file + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Path/PathTest.php b/tests/Cookies/Path/PathTest.php similarity index 63% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Path/PathTest.php rename to tests/Cookies/Path/PathTest.php index ccff932..1ac384a 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Path/PathTest.php +++ b/tests/Cookies/Path/PathTest.php @@ -4,9 +4,10 @@ use webignition\Tests\WebsiteRssFeedFinder\Cookies\CookiesTest; -abstract class PathTest extends CookiesTest { - - protected function getRootUrl() { +abstract class PathTest extends CookiesTest +{ + protected function getRootUrl() + { return 'http://example.com/foo'; - } -} \ No newline at end of file + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Secure/IsMatchTest.php b/tests/Cookies/Secure/IsMatchTest.php similarity index 73% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Secure/IsMatchTest.php rename to tests/Cookies/Secure/IsMatchTest.php index 1818907..db5aebf 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Secure/IsMatchTest.php +++ b/tests/Cookies/Secure/IsMatchTest.php @@ -2,17 +2,20 @@ namespace webignition\Tests\WebsiteRssFeedFinder\Cookies\Secure; -class IsMatchTest extends SecureTest { - - protected function getRootUrl() { +class IsMatchTest extends SecureTest +{ + protected function getRootUrl() + { return 'https://example.com/'; } - protected function getExpectedRequestsOnWhichCookiesShouldBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldBeSet() + { return $this->getAllSentHttpRequests(); } - protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() + { return array(); - } -} \ No newline at end of file + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Secure/NotMatchTest.php b/tests/Cookies/Secure/NotMatchTest.php similarity index 72% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Secure/NotMatchTest.php rename to tests/Cookies/Secure/NotMatchTest.php index 6b46c4a..57da96e 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Secure/NotMatchTest.php +++ b/tests/Cookies/Secure/NotMatchTest.php @@ -2,17 +2,20 @@ namespace webignition\Tests\WebsiteRssFeedFinder\Cookies\Secure; -class NotMatchTest extends SecureTest { - - protected function getRootUrl() { +class NotMatchTest extends SecureTest +{ + protected function getRootUrl() + { return 'http://example.com/'; } - protected function getExpectedRequestsOnWhichCookiesShouldBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldBeSet() + { return array(); } - protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() { + protected function getExpectedRequestsOnWhichCookiesShouldNotBeSet() + { return $this->getAllSentHttpRequests(); - } -} \ No newline at end of file + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Secure/SecureTest.php b/tests/Cookies/Secure/SecureTest.php similarity index 78% rename from tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Secure/SecureTest.php rename to tests/Cookies/Secure/SecureTest.php index dc01c5b..0fcc8e2 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Cookies/Secure/SecureTest.php +++ b/tests/Cookies/Secure/SecureTest.php @@ -4,9 +4,10 @@ use webignition\Tests\WebsiteRssFeedFinder\Cookies\CookiesTest; -abstract class SecureTest extends CookiesTest { - - protected function getCookies() { +abstract class SecureTest extends CookiesTest +{ + protected function getCookies() + { return array( array( 'domain' => '.example.com', @@ -16,5 +17,4 @@ protected function getCookies() { ) ); } - -} \ No newline at end of file +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Atom/GetUrlsTest.php b/tests/GetFeedUrls/Atom/GetUrlsTest.php similarity index 62% rename from tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Atom/GetUrlsTest.php rename to tests/GetFeedUrls/Atom/GetUrlsTest.php index 0026cba..8cf8348 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Atom/GetUrlsTest.php +++ b/tests/GetFeedUrls/Atom/GetUrlsTest.php @@ -4,10 +4,10 @@ use webignition\Tests\WebsiteRssFeedFinder\GetFeedUrls\GetFeedUrlsTest; -abstract class GetUrlsTest extends GetFeedUrlsTest { - - protected function getFeedUrls() { +abstract class GetUrlsTest extends GetFeedUrlsTest +{ + protected function getFeedUrls() + { return $this->getFeedFinder()->getAtomFeedUrls(); - } - -} \ No newline at end of file + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Atom/MultipleUrlsTest.php b/tests/GetFeedUrls/Atom/MultipleUrlsTest.php similarity index 62% rename from tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Atom/MultipleUrlsTest.php rename to tests/GetFeedUrls/Atom/MultipleUrlsTest.php index 7db8e25..4a3bdf4 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Atom/MultipleUrlsTest.php +++ b/tests/GetFeedUrls/Atom/MultipleUrlsTest.php @@ -2,13 +2,13 @@ namespace webignition\Tests\WebsiteRssFeedFinder\GetFeedUrls\Atom; -class MultipleUrlsTest extends GetUrlsTest { - - protected function getExpectedFeedUrls() { +class MultipleUrlsTest extends GetUrlsTest +{ + protected function getExpectedFeedUrls() + { return array( 'http://example.com/atom-1.xml', 'http://example.com/atom-2.xml' ); - } - -} \ No newline at end of file + } +} diff --git a/tests/GetFeedUrls/Atom/NoUrlTest.php b/tests/GetFeedUrls/Atom/NoUrlTest.php new file mode 100644 index 0000000..2410268 --- /dev/null +++ b/tests/GetFeedUrls/Atom/NoUrlTest.php @@ -0,0 +1,11 @@ +setHttpFixtures($this->getHttpFixtures($this->getFixturesDataPath(get_class($this), $this->getName() . '/HttpResponses'))); - + public function setUp() + { + $this->setHttpFixtures( + $this->getHttpFixtures( + $this->getFixturesDataPath(get_class($this), $this->getName() . '/HttpResponses') + ) + ); + $finder = $this->getFeedFinder(); - $finder->getConfiguration()->setRootUrl(self::ROOT_WEB_PAGE_URL); - } - - - public function testGetUrls() { - $this->assertEquals($this->getExpectedFeedUrls(), $this->getFeedUrls()); - } - - -} \ No newline at end of file + $finder->getConfiguration()->setRootUrl(self::ROOT_WEB_PAGE_URL); + } + + public function testGetUrls() + { + $this->assertEquals($this->getExpectedFeedUrls(), $this->getFeedUrls()); + } +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/HttpErrorRetrievingRootWebPage/ClientErrorTest.php b/tests/GetFeedUrls/HttpErrorRetrievingRootWebPage/ClientErrorTest.php similarity index 64% rename from tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/HttpErrorRetrievingRootWebPage/ClientErrorTest.php rename to tests/GetFeedUrls/HttpErrorRetrievingRootWebPage/ClientErrorTest.php index 4ffed7b..dfcd31a 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/HttpErrorRetrievingRootWebPage/ClientErrorTest.php +++ b/tests/GetFeedUrls/HttpErrorRetrievingRootWebPage/ClientErrorTest.php @@ -4,14 +4,15 @@ use webignition\Tests\WebsiteRssFeedFinder\GetFeedUrls\GetFeedUrlsTest; -class ClientErrorTest extends GetFeedUrlsTest { - - protected function getExpectedFeedUrls() { +class ClientErrorTest extends GetFeedUrlsTest +{ + protected function getExpectedFeedUrls() + { return null; } - protected function getFeedUrls() { + protected function getFeedUrls() + { return $this->getFeedFinder()->getRssFeedUrls(); } - -} \ No newline at end of file +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/HttpErrorRetrievingRootWebPage/ServerErrorTest.php b/tests/GetFeedUrls/HttpErrorRetrievingRootWebPage/ServerErrorTest.php similarity index 62% rename from tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/HttpErrorRetrievingRootWebPage/ServerErrorTest.php rename to tests/GetFeedUrls/HttpErrorRetrievingRootWebPage/ServerErrorTest.php index 99b30cc..33777ee 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/HttpErrorRetrievingRootWebPage/ServerErrorTest.php +++ b/tests/GetFeedUrls/HttpErrorRetrievingRootWebPage/ServerErrorTest.php @@ -4,14 +4,15 @@ use webignition\Tests\WebsiteRssFeedFinder\GetFeedUrls\GetFeedUrlsTest; -class ServerErrorTest extends GetFeedUrlsTest { - - protected function getExpectedFeedUrls() { +class ServerErrorTest extends GetFeedUrlsTest +{ + protected function getExpectedFeedUrls() + { return null; - } + } - protected function getFeedUrls() { + protected function getFeedUrls() + { return $this->getFeedFinder()->getRssFeedUrls(); } - -} \ No newline at end of file +} diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Rss/GetUrlsTest.php b/tests/GetFeedUrls/Rss/GetUrlsTest.php similarity index 63% rename from tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Rss/GetUrlsTest.php rename to tests/GetFeedUrls/Rss/GetUrlsTest.php index 9386768..708738b 100644 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Rss/GetUrlsTest.php +++ b/tests/GetFeedUrls/Rss/GetUrlsTest.php @@ -4,10 +4,10 @@ use webignition\Tests\WebsiteRssFeedFinder\GetFeedUrls\GetFeedUrlsTest; -abstract class GetUrlsTest extends GetFeedUrlsTest { - - protected function getFeedUrls() { +abstract class GetUrlsTest extends GetFeedUrlsTest +{ + protected function getFeedUrls() + { return $this->getFeedFinder()->getRssFeedUrls(); - } - -} \ No newline at end of file + } +} diff --git a/tests/GetFeedUrls/Rss/MultipleUrlsTest.php b/tests/GetFeedUrls/Rss/MultipleUrlsTest.php new file mode 100644 index 0000000..dab068a --- /dev/null +++ b/tests/GetFeedUrls/Rss/MultipleUrlsTest.php @@ -0,0 +1,14 @@ +httpClient)) { - $this->httpClient = new HttpClient(); - $this->httpClient->addSubscriber(new \Guzzle\Plugin\History\HistoryPlugin()); - } - - return $this->httpClient; - } - - - /** - * - * @return \Guzzle\Plugin\History\HistoryPlugin|null - */ - protected function getHttpHistory() { - $listenerCollections = $this->getHttpClient()->getEventDispatcher()->getListeners('request.sent'); - - foreach ($listenerCollections as $listener) { - if ($listener[0] instanceof \Guzzle\Plugin\History\HistoryPlugin) { - return $listener[0]; - } - } - - return null; - } - - - protected function setHttpFixtures($fixtures) { - $plugin = new \Guzzle\Plugin\Mock\MockPlugin(); - - foreach ($fixtures as $fixture) { - $plugin->addResponse($fixture); - } - - $this->getHttpClient()->addSubscriber($plugin); - } - - - protected function getHttpFixtures($path) { - $fixtures = array(); - $fixturesDirectory = new \DirectoryIterator($path); - - $fixturePathnames = array(); - - foreach ($fixturesDirectory as $directoryItem) { - if ($directoryItem->isFile()) { - $fixturePathnames[] = $directoryItem->getPathname(); - } - } - - sort($fixturePathnames); - - foreach ($fixturePathnames as $fixturePathname) { - $fixtures[] = \Guzzle\Http\Message\Response::fromMessage(file_get_contents($fixturePathname)); - } - - return $fixtures; - } - - - /** - * - * @param string $testName - * @return string - */ - protected function getFixturesDataPath($className, $testName = null) { - $path = __DIR__ . '/../../../fixtures/' . str_replace('\\', DIRECTORY_SEPARATOR, $className); - - if (!is_null($testName)) { - $path .= '/' . $testName; - } - - return $path; - } - - - - /** - * - * @return \webignition\WebsiteRssFeedFinder\WebsiteRssFeedFinder - */ - protected function getFeedFinder() { - if (is_null($this->feedFinder)) { - $this->feedFinder = new \webignition\WebsiteRssFeedFinder\WebsiteRssFeedFinder(); - $this->feedFinder->getConfiguration()->setBaseRequest($this->getHttpClient()->get()); - } - - return $this->feedFinder; - } - - - /** - * - * @param array $items Collection of http messages and/or curl exceptions - * @return array - */ - protected function buildHttpFixtureSet($items) { - $fixtures = array(); - - foreach ($items as $item) { - switch ($this->getHttpFixtureItemType($item)) { - case 'httpMessage': - $fixtures[] = \Guzzle\Http\Message\Response::fromMessage($item); - break; - - case 'curlException': - $fixtures[] = $this->getCurlExceptionFromCurlMessage($item); - break; - - default: - throw new \LogicException(); - } - } - - return $fixtures; - } - - - /** - * - * @param string $item - * @return string - */ - private function getHttpFixtureItemType($item) { - if (substr($item, 0, strlen('HTTP')) == 'HTTP') { - return 'httpMessage'; - } - - return 'curlException'; - } - - -} \ No newline at end of file diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/RootUrlTest.php b/tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/RootUrlTest.php deleted file mode 100644 index c88e267..0000000 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/Configuration/RootUrlTest.php +++ /dev/null @@ -1,24 +0,0 @@ -assertNull($this->configuration->getRootUrl()); - } - - public function testSetReturnsSelf() { - $this->assertEquals($this->configuration, $this->configuration->setRootUrl(self::ROOT_URL)); - } - - public function testGetReturnsValueSet() { - $this->assertEquals(self::ROOT_URL, (string)$this->configuration->setRootUrl(self::ROOT_URL)->getRootUrl()); - } - - public function testGetReturnsNormalizedUrlObject() { - $this->assertInstanceOf('webignition\NormalisedUrl\NormalisedUrl', $this->configuration->setRootUrl(self::ROOT_URL)->getRootUrl()); - } -} \ No newline at end of file diff --git a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Atom/NoUrlTest.php b/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Atom/NoUrlTest.php deleted file mode 100644 index a7170dc..0000000 --- a/tests/webignition/Tests/WebsiteRssFeedFinder/GetFeedUrls/Atom/NoUrlTest.php +++ /dev/null @@ -1,11 +0,0 @@ -