From 525c7ac95e42e1aca356f124fe0d20134a3906bd Mon Sep 17 00:00:00 2001 From: Josemar Lohn Date: Sat, 7 Aug 2021 04:49:44 -0300 Subject: [PATCH 01/12] Update packages --- composer.json | 8 +- composer.lock | 2184 +++++++++++++++++++++++++++++++++++-------------- 2 files changed, 1564 insertions(+), 628 deletions(-) diff --git a/composer.json b/composer.json index bf65b93..9136b87 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,6 @@ "p3k/http": ">=0.1.11", "cebe/markdown": "1.1.*", "p3k/picofeed": ">=0.1.39", - "facebook/graph-sdk": "^5.5", "masterminds/html5": "^2.3" }, "autoload": { @@ -28,7 +27,7 @@ "require-dev": { "league/plates": "3.*", "league/route": "1.*", - "phpunit/phpunit": "4.8.*" + "phpunit/phpunit": "^9.0.0" }, "autoload-dev": { "files": [ @@ -39,5 +38,8 @@ "controllers/Feeds.php", "controllers/Certbot.php" ] + }, + "scripts": { + "test": "vendor/bin/phpunit" } -} +} \ No newline at end of file diff --git a/composer.lock b/composer.lock index 6e6abaf..b4c1e45 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "383c315ac9fc68ab5443e1386772e6a7", + "content-hash": "61cbed43047036764edd6eb8d53492b4", "packages": [ { "name": "cebe/markdown", @@ -64,6 +64,10 @@ "markdown", "markdown-extra" ], + "support": { + "issues": "https://github.com/cebe/markdown/issues", + "source": "https://github.com/cebe/markdown" + }, "time": "2017-07-16T21:13:23+00:00" }, { @@ -106,20 +110,24 @@ "oauth", "twitter" ], + "support": { + "issues": "https://github.com/dg/twitter-php/issues", + "source": "https://github.com/dg/twitter-php/tree/v3.6" + }, "time": "2016-08-15T16:46:22+00:00" }, { "name": "ezyang/htmlpurifier", - "version": "v4.12.0", + "version": "v4.13.0", "source": { "type": "git", "url": "https://github.com/ezyang/htmlpurifier.git", - "reference": "a617e55bc62a87eec73bd456d146d134ad716f03" + "reference": "08e27c97e4c6ed02f37c5b2b20488046c8d90d75" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/a617e55bc62a87eec73bd456d146d134ad716f03", - "reference": "a617e55bc62a87eec73bd456d146d134ad716f03", + "url": "https://api.github.com/repos/ezyang/htmlpurifier/zipball/08e27c97e4c6ed02f37c5b2b20488046c8d90d75", + "reference": "08e27c97e4c6ed02f37c5b2b20488046c8d90d75", "shasum": "" }, "require": { @@ -135,6 +143,9 @@ }, "files": [ "library/HTMLPurifier.composer.php" + ], + "exclude-from-classmap": [ + "/library/HTMLPurifier/Language/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -153,65 +164,11 @@ "keywords": [ "html" ], - "time": "2019-10-28T03:44:26+00:00" - }, - { - "name": "facebook/graph-sdk", - "version": "5.7.0", - "source": { - "type": "git", - "url": "https://github.com/facebook/php-graph-sdk.git", - "reference": "2d8250638b33d73e7a87add65f47fabf91f8ad9b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/facebook/php-graph-sdk/zipball/2d8250638b33d73e7a87add65f47fabf91f8ad9b", - "reference": "2d8250638b33d73e7a87add65f47fabf91f8ad9b", - "shasum": "" - }, - "require": { - "php": "^5.4|^7.0" - }, - "require-dev": { - "guzzlehttp/guzzle": "~5.0", - "mockery/mockery": "~0.8", - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "guzzlehttp/guzzle": "Allows for implementation of the Guzzle HTTP client", - "paragonie/random_compat": "Provides a better CSPRNG option in PHP 5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "Facebook\\": "src/Facebook/" - }, - "files": [ - "src/Facebook/polyfills.php" - ] + "support": { + "issues": "https://github.com/ezyang/htmlpurifier/issues", + "source": "https://github.com/ezyang/htmlpurifier/tree/master" }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Facebook Platform" - ], - "authors": [ - { - "name": "Facebook", - "homepage": "https://github.com/facebook/php-graph-sdk/contributors" - } - ], - "description": "Facebook SDK for PHP", - "homepage": "https://github.com/facebook/php-graph-sdk", - "keywords": [ - "facebook", - "sdk" - ], - "time": "2018-12-11T22:56:31+00:00" + "time": "2020-06-29T00:56:53+00:00" }, { "name": "indieweb/link-rel-parser", @@ -257,40 +214,39 @@ "indieweb", "microformats2" ], + "support": { + "issues": "https://github.com/indieweb/link-rel-parser-php/issues", + "source": "https://github.com/indieweb/link-rel-parser-php/tree/master" + }, "time": "2017-01-11T17:14:49+00:00" }, { "name": "laminas/laminas-xml", - "version": "1.2.0", + "version": "1.3.1", "source": { "type": "git", "url": "https://github.com/laminas/laminas-xml.git", - "reference": "879cc66d1bba6a37705e98074f52a6960c220020" + "reference": "2eada592359aec9d9e55339270b621295cff3a4f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-xml/zipball/879cc66d1bba6a37705e98074f52a6960c220020", - "reference": "879cc66d1bba6a37705e98074f52a6960c220020", + "url": "https://api.github.com/repos/laminas/laminas-xml/zipball/2eada592359aec9d9e55339270b621295cff3a4f", + "reference": "2eada592359aec9d9e55339270b621295cff3a4f", "shasum": "" }, "require": { "laminas/laminas-zendframework-bridge": "^1.0", - "php": "^5.6 || ^7.0" + "php": "^7.3 || ~8.0.0" }, "replace": { - "zendframework/zendxml": "self.version" + "zendframework/zendxml": "^1.2.0" }, "require-dev": { + "ext-iconv": "*", "laminas/laminas-coding-standard": "~1.0.0", - "phpunit/phpunit": "^5.7.27 || ^6.5.8 || ^7.1.4" + "phpunit/phpunit": "^9.4" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev", - "dev-develop": "1.3.x-dev" - } - }, "autoload": { "psr-4": { "Laminas\\Xml\\": "src/" @@ -307,35 +263,46 @@ "security", "xml" ], - "time": "2019-12-31T18:05:42+00:00" + "support": { + "chat": "https://laminas.dev/chat", + "forum": "https://discourse.laminas.dev", + "issues": "https://github.com/laminas/laminas-xml/issues", + "rss": "https://github.com/laminas/laminas-xml/releases.atom", + "source": "https://github.com/laminas/laminas-xml" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-02-17T22:44:58+00:00" }, { "name": "laminas/laminas-zendframework-bridge", - "version": "1.0.3", + "version": "1.3.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-zendframework-bridge.git", - "reference": "bfbbdb6c998d50dbf69d2187cb78a5f1fa36e1e9" + "reference": "13af2502d9bb6f7d33be2de4b51fb68c6cdb476e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/bfbbdb6c998d50dbf69d2187cb78a5f1fa36e1e9", - "reference": "bfbbdb6c998d50dbf69d2187cb78a5f1fa36e1e9", + "url": "https://api.github.com/repos/laminas/laminas-zendframework-bridge/zipball/13af2502d9bb6f7d33be2de4b51fb68c6cdb476e", + "reference": "13af2502d9bb6f7d33be2de4b51fb68c6cdb476e", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0" + "php": "^7.3 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1", - "squizlabs/php_codesniffer": "^3.5" + "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.1 || ^9.3", + "psalm/plugin-phpunit": "^0.15.1", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.6" }, "type": "library", "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev", - "dev-develop": "1.1.x-dev" - }, "laminas": { "module": "Laminas\\ZendFrameworkBridge" } @@ -359,20 +326,32 @@ "laminas", "zf" ], - "time": "2020-04-03T16:01:00+00:00" + "support": { + "forum": "https://discourse.laminas.dev/", + "issues": "https://github.com/laminas/laminas-zendframework-bridge/issues", + "rss": "https://github.com/laminas/laminas-zendframework-bridge/releases.atom", + "source": "https://github.com/laminas/laminas-zendframework-bridge" + }, + "funding": [ + { + "url": "https://funding.communitybridge.org/projects/laminas-project", + "type": "community_bridge" + } + ], + "time": "2021-06-24T12:49:22+00:00" }, { "name": "masterminds/html5", - "version": "2.7.0", + "version": "2.7.5", "source": { "type": "git", "url": "https://github.com/Masterminds/html5-php.git", - "reference": "104443ad663d15981225f99532ba73c2f1d6b6f2" + "reference": "f640ac1bdddff06ea333a920c95bbad8872429ab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/104443ad663d15981225f99532ba73c2f1d6b6f2", - "reference": "104443ad663d15981225f99532ba73c2f1d6b6f2", + "url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f640ac1bdddff06ea333a920c95bbad8872429ab", + "reference": "f640ac1bdddff06ea333a920c95bbad8872429ab", "shasum": "" }, "require": { @@ -382,9 +361,7 @@ "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35", - "sami/sami": "~2.0", - "satooshi/php-coveralls": "1.0.*" + "phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7" }, "type": "library", "extra": { @@ -426,7 +403,11 @@ "serializer", "xml" ], - "time": "2019-07-25T07:03:26+00:00" + "support": { + "issues": "https://github.com/Masterminds/html5-php/issues", + "source": "https://github.com/Masterminds/html5-php/tree/2.7.5" + }, + "time": "2021-07-01T14:25:37+00:00" }, { "name": "mf2/mf2", @@ -482,6 +463,10 @@ "parser", "semantic" ], + "support": { + "issues": "https://github.com/microformats/php-mf2/issues", + "source": "https://github.com/microformats/php-mf2/tree/master" + }, "time": "2018-08-24T14:47:04+00:00" }, { @@ -520,20 +505,24 @@ ], "description": "A simple wrapper API around the PHP curl functions", "homepage": "https://github.com/aaronpk/p3k-http", + "support": { + "issues": "https://github.com/aaronpk/p3k-http/issues", + "source": "https://github.com/aaronpk/p3k-http/tree/master" + }, "time": "2020-02-19T03:00:09+00:00" }, { "name": "p3k/picofeed", - "version": "v0.1.39", + "version": "v0.1.40", "source": { "type": "git", "url": "https://github.com/aaronpk/picofeed.git", - "reference": "2c6469ce845db0f26b80b32eb18758cdc62a33ed" + "reference": "356fd66d48779193b10ac28532cb4a4e11bb801c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/aaronpk/picofeed/zipball/2c6469ce845db0f26b80b32eb18758cdc62a33ed", - "reference": "2c6469ce845db0f26b80b32eb18758cdc62a33ed", + "url": "https://api.github.com/repos/aaronpk/picofeed/zipball/356fd66d48779193b10ac28532cb4a4e11bb801c", + "reference": "356fd66d48779193b10ac28532cb4a4e11bb801c", "shasum": "" }, "require": { @@ -545,6 +534,9 @@ "laminas/laminas-xml": "^1.2", "php": ">=5.3.0" }, + "replace": { + "miniflux/picofeed": "0.1.35" + }, "require-dev": { "phpdocumentor/reflection-docblock": "2.0.4", "phpunit/phpunit": "4.8.26", @@ -573,7 +565,11 @@ ], "description": "Modern library to handle RSS/Atom feeds", "homepage": "https://github.com/aaronpk/picoFeed", - "time": "2020-04-18T23:59:05+00:00" + "support": { + "issues": "https://github.com/aaronpk/picofeed/issues", + "source": "https://github.com/aaronpk/picofeed/tree/v0.1.40" + }, + "time": "2020-04-25T17:48:36+00:00" }, { "name": "p3k/timezone", @@ -598,6 +594,7 @@ "src/p3k/Timezone.php" ] }, + "notification-url": "https://packagist.org/downloads/", "license": [ "Apache-2.0" ], @@ -614,42 +611,41 @@ "p3k", "timezone" ], + "support": { + "issues": "https://github.com/aaronpk/p3k-timezone/issues", + "source": "https://github.com/aaronpk/p3k-timezone/tree/0.1.0" + }, "time": "2017-01-12T17:30:08+00:00" } ], "packages-dev": [ { "name": "doctrine/instantiator", - "version": "1.3.0", + "version": "1.4.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1" + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/ae466f726242e637cebdd526a7d991b9433bacf1", - "reference": "ae466f726242e637cebdd526a7d991b9433bacf1", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/d56bf6102915de5702778fe20f2de3b2fe570b5b", + "reference": "d56bf6102915de5702778fe20f2de3b2fe570b5b", "shasum": "" }, "require": { - "php": "^7.1" + "php": "^7.1 || ^8.0" }, "require-dev": { - "doctrine/coding-standard": "^6.0", + "doctrine/coding-standard": "^8.0", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.13", - "phpstan/phpstan-phpunit": "^0.11", - "phpstan/phpstan-shim": "^0.11", - "phpunit/phpunit": "^7.0" + "phpbench/phpbench": "^0.13 || 1.0.0-alpha2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, "autoload": { "psr-4": { "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" @@ -663,7 +659,7 @@ { "name": "Marco Pivetta", "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" + "homepage": "https://ocramius.github.io/" } ], "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", @@ -672,49 +668,25 @@ "constructor", "instantiate" ], - "time": "2019-10-21T16:45:58+00:00" - }, - { - "name": "ircmaxell/password-compat", - "version": "v1.0.4", - "source": { - "type": "git", - "url": "https://github.com/ircmaxell/password_compat.git", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ircmaxell/password_compat/zipball/5c5cde8822a69545767f7c7f3058cb15ff84614c", - "reference": "5c5cde8822a69545767f7c7f3058cb15ff84614c", - "shasum": "" + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/1.4.0" }, - "require-dev": { - "phpunit/phpunit": "4.*" - }, - "type": "library", - "autoload": { - "files": [ - "lib/password.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, { - "name": "Anthony Ferrara", - "email": "ircmaxell@php.net", - "homepage": "http://blog.ircmaxell.com" + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" } ], - "description": "A compatibility library for the proposed simplified password hashing algorithm: https://wiki.php.net/rfc/password_hash", - "homepage": "https://github.com/ircmaxell/password_compat", - "keywords": [ - "hashing", - "password" - ], - "time": "2014-11-20T16:49:30+00:00" + "time": "2020-11-10T18:47:58+00:00" }, { "name": "league/container", @@ -772,29 +744,33 @@ "injection", "league" ], + "support": { + "issues": "https://github.com/thephpleague/container/issues", + "source": "https://github.com/thephpleague/container/tree/1.x" + }, "time": "2015-04-05T17:14:48+00:00" }, { "name": "league/plates", - "version": "3.3.0", + "version": "v3.4.0", "source": { "type": "git", "url": "https://github.com/thephpleague/plates.git", - "reference": "b1684b6f127714497a0ef927ce42c0b44b45a8af" + "reference": "6d3ee31199b536a4e003b34a356ca20f6f75496a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/plates/zipball/b1684b6f127714497a0ef927ce42c0b44b45a8af", - "reference": "b1684b6f127714497a0ef927ce42c0b44b45a8af", + "url": "https://api.github.com/repos/thephpleague/plates/zipball/6d3ee31199b536a4e003b34a356ca20f6f75496a", + "reference": "6d3ee31199b536a4e003b34a356ca20f6f75496a", "shasum": "" }, "require": { - "php": "^5.3 | ^7.0" + "php": "^7.0|^8.0" }, "require-dev": { - "mikey179/vfsstream": "^1.4", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~1.5" + "mikey179/vfsstream": "^1.6", + "phpunit/phpunit": "^9.5", + "squizlabs/php_codesniffer": "^3.5" }, "type": "library", "extra": { @@ -816,10 +792,15 @@ "name": "Jonathan Reinink", "email": "jonathan@reinink.ca", "role": "Developer" + }, + { + "name": "RJ Garcia", + "email": "ragboyjr@icloud.com", + "role": "Developer" } ], "description": "Plates, the native PHP template system that's fast, easy to use and easy to extend.", - "homepage": "http://platesphp.com", + "homepage": "https://platesphp.com", "keywords": [ "league", "package", @@ -827,7 +808,11 @@ "templating", "views" ], - "time": "2016-12-28T00:14:17+00:00" + "support": { + "issues": "https://github.com/thephpleague/plates/issues", + "source": "https://github.com/thephpleague/plates/tree/v3.4.0" + }, + "time": "2020-12-25T05:00:37+00:00" }, { "name": "league/route", @@ -885,8 +870,70 @@ "league", "route" ], + "support": { + "issues": "https://github.com/thephpleague/route/issues", + "source": "https://github.com/thephpleague/route/tree/1.x" + }, "time": "2015-09-11T07:40:31+00:00" }, + { + "name": "myclabs/deep-copy", + "version": "1.10.2", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/776f831124e9c62e1a2c601ecc52e776d8bb7220", + "reference": "776f831124e9c62e1a2c601ecc52e776d8bb7220", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "replace": { + "myclabs/deep-copy": "self.version" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^7.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "support": { + "issues": "https://github.com/myclabs/DeepCopy/issues", + "source": "https://github.com/myclabs/DeepCopy/tree/1.10.2" + }, + "funding": [ + { + "url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy", + "type": "tidelift" + } + ], + "time": "2020-11-13T09:40:50+00:00" + }, { "name": "nikic/fast-route", "version": "v0.8.0", @@ -928,192 +975,205 @@ "router", "routing" ], + "support": { + "issues": "https://github.com/nikic/FastRoute/issues", + "source": "https://github.com/nikic/FastRoute/tree/master" + }, "time": "2016-03-25T23:46:52+00:00" }, { - "name": "phpdocumentor/reflection-common", - "version": "2.0.0", + "name": "nikic/php-parser", + "version": "v4.12.0", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a" + "url": "https://github.com/nikic/PHP-Parser.git", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/63a995caa1ca9e5590304cd845c15ad6d482a62a", - "reference": "63a995caa1ca9e5590304cd845c15ad6d482a62a", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/6608f01670c3cc5079e18c1dab1104e002579143", + "reference": "6608f01670c3cc5079e18c1dab1104e002579143", "shasum": "" }, "require": { - "php": ">=7.1" + "ext-tokenizer": "*", + "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "~6" + "ircmaxell/php-yacc": "^0.0.7", + "phpunit/phpunit": "^6.5 || ^7.0 || ^8.0 || ^9.0" }, + "bin": [ + "bin/php-parse" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "4.9-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": "src/" + "PhpParser\\": "lib/PhpParser" } }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" + "name": "Nikita Popov" } ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", + "description": "A PHP parser written in PHP", "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" + "parser", + "php" ], - "time": "2018-08-07T13:53:10+00:00" + "support": { + "issues": "https://github.com/nikic/PHP-Parser/issues", + "source": "https://github.com/nikic/PHP-Parser/tree/v4.12.0" + }, + "time": "2021-07-21T10:44:31+00:00" }, { - "name": "phpdocumentor/reflection-docblock", - "version": "4.3.2", + "name": "phar-io/manifest", + "version": "2.0.3", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e" + "url": "https://github.com/phar-io/manifest.git", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/b83ff7cfcfee7827e1e78b637a5904fe6a96698e", - "reference": "b83ff7cfcfee7827e1e78b637a5904fe6a96698e", + "url": "https://api.github.com/repos/phar-io/manifest/zipball/97803eca37d319dfa7826cc2437fc020857acb53", + "reference": "97803eca37d319dfa7826cc2437fc020857acb53", "shasum": "" }, "require": { - "php": "^7.0", - "phpdocumentor/reflection-common": "^1.0.0 || ^2.0.0", - "phpdocumentor/type-resolver": "~0.4 || ^1.0.0", - "webmozart/assert": "^1.0" - }, - "require-dev": { - "doctrine/instantiator": "^1.0.5", - "mockery/mockery": "^1.0", - "phpunit/phpunit": "^6.4" + "ext-dom": "*", + "ext-phar": "*", + "ext-xmlwriter": "*", + "phar-io/version": "^3.0.1", + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "2.0.x-dev" } }, "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": [ - "src/" - ] - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" } ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "time": "2019-09-12T14:27:41+00:00" + "description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)", + "support": { + "issues": "https://github.com/phar-io/manifest/issues", + "source": "https://github.com/phar-io/manifest/tree/2.0.3" + }, + "time": "2021-07-20T11:28:43+00:00" }, { - "name": "phpdocumentor/type-resolver", - "version": "1.0.1", + "name": "phar-io/version", + "version": "3.1.0", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9" + "url": "https://github.com/phar-io/version.git", + "reference": "bae7c545bef187884426f042434e561ab1ddb182" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", - "reference": "2e32a6d48972b2c1976ed5d8967145b6cec4a4a9", + "url": "https://api.github.com/repos/phar-io/version/zipball/bae7c545bef187884426f042434e561ab1ddb182", + "reference": "bae7c545bef187884426f042434e561ab1ddb182", "shasum": "" }, "require": { - "php": "^7.1", - "phpdocumentor/reflection-common": "^2.0" - }, - "require-dev": { - "ext-tokenizer": "^7.1", - "mockery/mockery": "~1", - "phpunit/phpunit": "^7.0" + "php": "^7.2 || ^8.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } + "classmap": [ + "src/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + }, + { + "name": "Sebastian Heuer", + "email": "sebastian@phpeople.de", + "role": "Developer" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "Developer" } ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "time": "2019-08-22T18:11:29+00:00" + "description": "Library for handling version information and constraints", + "support": { + "issues": "https://github.com/phar-io/version/issues", + "source": "https://github.com/phar-io/version/tree/3.1.0" + }, + "time": "2021-02-23T14:00:09+00:00" }, { - "name": "phpspec/prophecy", - "version": "1.9.0", + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", "source": { "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203" + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/f6811d96d97bdf400077a0cc100ae56aa32b9203", - "reference": "f6811d96d97bdf400077a0cc100ae56aa32b9203", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0|^5.0", - "sebastian/comparator": "^1.1|^2.0|^3.0", - "sebastian/recursion-context": "^1.0|^2.0|^3.0" - }, - "require-dev": { - "phpspec/phpspec": "^2.5|^3.2", - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + "php": "^7.2 || ^8.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.8.x-dev" + "dev-2.x": "2.x-dev" } }, "autoload": { "psr-4": { - "Prophecy\\": "src/Prophecy" + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1122,62 +1182,237 @@ ], "authors": [ { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" } ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" ], - "time": "2019-10-03T11:07:50+00:00" + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" }, { - "name": "phpunit/php-code-coverage", - "version": "2.2.4", + "name": "phpdocumentor/reflection-docblock", + "version": "5.2.2", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/069a785b2141f5bcf49f3e353548dc1cce6df556", + "reference": "069a785b2141f5bcf49f3e353548dc1cce6df556", "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" + "ext-filter": "*", + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.3", + "webmozart/assert": "^1.9.1" }, "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" + "mockery/mockery": "~1.3.2" }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.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" + }, + { + "name": "Jaap van Otterdijk", + "email": "account@ijaap.nl" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" + }, + "time": "2020-09-03T19:13:55+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "reference": "6a467b8989322d92aa1c8bf2bebcc6e5c2ba55c0", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0", + "phpdocumentor/reflection-common": "^2.0" + }, + "require-dev": { + "ext-tokenizer": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-1.x": "1.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" + } + ], + "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "support": { + "issues": "https://github.com/phpDocumentor/TypeResolver/issues", + "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0" + }, + "time": "2020-09-17T18:55:26+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.13.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea", + "reference": "be1996ed8adc35c3fd795488a653f4b518be70ea", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.2", + "php": "^7.2 || ~8.0, <8.1", + "phpdocumentor/reflection-docblock": "^5.2", + "sebastian/comparator": "^3.0 || ^4.0", + "sebastian/recursion-context": "^3.0 || ^4.0" + }, + "require-dev": { + "phpspec/phpspec": "^6.0", + "phpunit/phpunit": "^8.0 || ^9.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Prophecy\\": "src/Prophecy" + } + }, + "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" + ], + "support": { + "issues": "https://github.com/phpspec/prophecy/issues", + "source": "https://github.com/phpspec/prophecy/tree/1.13.0" + }, + "time": "2021-03-17T13:42:18+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "9.2.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "f6293e1b30a2354e8428e004689671b83871edde" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde", + "reference": "f6293e1b30a2354e8428e004689671b83871edde", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-libxml": "*", + "ext-xmlwriter": "*", + "nikic/php-parser": "^4.10.2", + "php": ">=7.3", + "phpunit/php-file-iterator": "^3.0.3", + "phpunit/php-text-template": "^2.0.2", + "sebastian/code-unit-reverse-lookup": "^2.0.2", + "sebastian/complexity": "^2.0", + "sebastian/environment": "^5.1.2", + "sebastian/lines-of-code": "^1.0.3", + "sebastian/version": "^3.0.1", + "theseer/tokenizer": "^1.2.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcov": "*", + "ext-xdebug": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.2.x-dev" + "dev-master": "9.2-dev" } }, "autoload": { @@ -1192,7 +1427,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1203,29 +1438,42 @@ "testing", "xunit" ], - "time": "2015-10-06T15:47:00+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2021-03-28T07:26:59+00:00" }, { "name": "phpunit/php-file-iterator", - "version": "1.4.5", + "version": "3.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", - "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/aa4be8575f26070b100fccb67faabb28f21f66f8", + "reference": "aa4be8575f26070b100fccb67faabb28f21f66f8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4.x-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1240,7 +1488,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1250,26 +1498,107 @@ "filesystem", "iterator" ], - "time": "2017-11-27T13:52:08+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/php-file-iterator/issues", + "source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:57:25+00:00" + }, + { + "name": "phpunit/php-invoker", + "version": "3.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-invoker.git", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "reference": "5a10147d0aaf65b58940a0b72f71c9ac0423cc67", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "ext-pcntl": "*", + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-pcntl": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-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": "Invoke callables with a timeout", + "homepage": "https://github.com/sebastianbergmann/php-invoker/", + "keywords": [ + "process" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/php-invoker/issues", + "source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:58:55+00:00" }, { "name": "phpunit/php-text-template", - "version": "1.2.1", + "version": "2.0.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", + "reference": "5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1291,32 +1620,42 @@ "keywords": [ "template" ], - "time": "2015-06-21T13:50:34+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/php-text-template/issues", + "source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T05:33:50+00:00" }, { "name": "phpunit/php-timer", - "version": "1.0.9", + "version": "5.0.3", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", - "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", + "reference": "5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1331,7 +1670,7 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", + "email": "sebastian@phpunit.de", "role": "lead" } ], @@ -1340,38 +1679,85 @@ "keywords": [ "timer" ], - "time": "2017-02-26T11:10:40+00:00" + "support": { + "issues": "https://github.com/sebastianbergmann/php-timer/issues", + "source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:16:10+00:00" }, { - "name": "phpunit/php-token-stream", - "version": "1.4.12", + "name": "phpunit/phpunit", + "version": "9.5.8", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "191768ccd5c85513b4068bdbe99bb6390c7d54fb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", - "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/191768ccd5c85513b4068bdbe99bb6390c7d54fb", + "reference": "191768ccd5c85513b4068bdbe99bb6390c7d54fb", "shasum": "" }, "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" + "doctrine/instantiator": "^1.3.1", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "ext-xmlwriter": "*", + "myclabs/deep-copy": "^1.10.1", + "phar-io/manifest": "^2.0.3", + "phar-io/version": "^3.0.2", + "php": ">=7.3", + "phpspec/prophecy": "^1.12.1", + "phpunit/php-code-coverage": "^9.2.3", + "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-invoker": "^3.1.1", + "phpunit/php-text-template": "^2.0.3", + "phpunit/php-timer": "^5.0.2", + "sebastian/cli-parser": "^1.0.1", + "sebastian/code-unit": "^1.0.6", + "sebastian/comparator": "^4.0.5", + "sebastian/diff": "^4.0.3", + "sebastian/environment": "^5.1.3", + "sebastian/exporter": "^4.0.3", + "sebastian/global-state": "^5.0.1", + "sebastian/object-enumerator": "^4.0.3", + "sebastian/resource-operations": "^3.0.3", + "sebastian/type": "^2.3.4", + "sebastian/version": "^3.0.2" }, "require-dev": { - "phpunit/phpunit": "~4.2" + "ext-pdo": "*", + "phpspec/prophecy-phpunit": "^2.0.1" + }, + "suggest": { + "ext-soap": "*", + "ext-xdebug": "*" }, + "bin": [ + "phpunit" + ], "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "9.5-dev" } }, "autoload": { "classmap": [ "src/" + ], + "files": [ + "src/Framework/Assert/Functions.php" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1381,61 +1767,57 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "description": "The PHP Unit Testing framework.", + "homepage": "https://phpunit.de/", "keywords": [ - "tokenizer" + "phpunit", + "testing", + "xunit" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/phpunit/issues", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.8" + }, + "funding": [ + { + "url": "https://phpunit.de/donate.html", + "type": "custom" + }, + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2017-12-04T08:55:13+00:00" + "time": "2021-07-31T15:17:34+00:00" }, { - "name": "phpunit/phpunit", - "version": "4.8.36", + "name": "sebastian/cli-parser", + "version": "1.0.1", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517" + "url": "https://github.com/sebastianbergmann/cli-parser.git", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/46023de9a91eec7dfb06cc56cb4e260017298517", - "reference": "46023de9a91eec7dfb06cc56cb4e260017298517", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/442e7c7e687e42adc03470c7b668bc4b2402c0b2", + "reference": "442e7c7e687e42adc03470c7b668bc4b2402c0b2", "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" + "php": ">=7.3" }, - "suggest": { - "phpunit/php-invoker": "~1.1" + "require-dev": { + "phpunit/phpunit": "^9.3" }, - "bin": [ - "phpunit" - ], "type": "library", "extra": { "branch-alias": { - "dev-master": "4.8.x-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -1449,50 +1831,503 @@ ], "authors": [ { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library for parsing CLI options", + "homepage": "https://github.com/sebastianbergmann/cli-parser", + "support": { + "issues": "https://github.com/sebastianbergmann/cli-parser/issues", + "source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:08:49+00:00" + }, + { + "name": "sebastian/code-unit", + "version": "1.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit.git", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit/zipball/1fc9f64c0927627ef78ba436c9b17d967e68e120", + "reference": "1fc9f64c0927627ef78ba436c9b17d967e68e120", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "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", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the PHP code units", + "homepage": "https://github.com/sebastianbergmann/code-unit", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit/issues", + "source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:08:54+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "2.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "reference": "ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "support": { + "issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues", + "source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:30:19+00:00" + }, + { + "name": "sebastian/comparator", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", + "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/diff": "^4.0", + "sebastian/exporter": "^4.0" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "https://github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/comparator/issues", + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:49:45+00:00" + }, + { + "name": "sebastian/complexity", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/complexity.git", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/complexity/zipball/739b35e53379900cc9ac327b2147867b8b6efd88", + "reference": "739b35e53379900cc9ac327b2147867b8b6efd88", + "shasum": "" + }, + "require": { + "nikic/php-parser": "^4.7", + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-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": "Library for calculating the complexity of PHP code units", + "homepage": "https://github.com/sebastianbergmann/complexity", + "support": { + "issues": "https://github.com/sebastianbergmann/complexity/issues", + "source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T15:52:27+00:00" + }, + { + "name": "sebastian/diff", + "version": "4.0.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "reference": "3461e3fccc7cfdfc2720be910d3bd73c69be590d", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3", + "symfony/process": "^4.2 || ^5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff", + "udiff", + "unidiff", + "unified diff" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/diff/issues", + "source": "https://github.com/sebastianbergmann/diff/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-10-26T13:10:38+00:00" + }, + { + "name": "sebastian/environment", + "version": "5.1.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", + "reference": "388b6ced16caa751030f6a69e588299fa09200ac", + "shasum": "" + }, + "require": { + "php": ">=7.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3" + }, + "suggest": { + "ext-posix": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.1-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" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/environment/issues", + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T05:52:38+00:00" + }, + { + "name": "sebastian/exporter", + "version": "4.0.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "reference": "d89cc98761b8cb5a1a235a6b703ae50d34080e65", + "shasum": "" + }, + "require": { + "php": ">=7.3", + "sebastian/recursion-context": "^4.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "^9.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" } ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", "keywords": [ - "phpunit", - "testing", - "xunit" + "export", + "exporter" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/exporter/issues", + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2017-06-21T08:07:12+00:00" + "time": "2020-09-28T05:24:23+00:00" }, { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", + "name": "sebastian/global-state", + "version": "5.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/23bd5951f7ff26f12d4e3242864df3e08dec4e49", + "reference": "23bd5951f7ff26f12d4e3242864df3e08dec4e49", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "ext-dom": "*", + "phpunit/phpunit": "^9.3" }, "suggest": { - "ext-soap": "*" + "ext-uopz": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.3.x-dev" + "dev-master": "5.0-dev" } }, "autoload": { @@ -1507,45 +2342,51 @@ "authors": [ { "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" + "email": "sebastian@phpunit.de" } ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", "keywords": [ - "mock", - "xunit" + "global state" + ], + "support": { + "issues": "https://github.com/sebastianbergmann/global-state/issues", + "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "abandoned": true, - "time": "2015-10-02T06:51:40+00:00" + "time": "2021-06-11T13:31:12+00:00" }, { - "name": "sebastian/comparator", - "version": "1.2.4", + "name": "sebastian/lines-of-code", + "version": "1.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + "url": "https://github.com/sebastianbergmann/lines-of-code.git", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", - "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "url": "https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/c1c2e997aa3146983ed888ad08b15470a2e22ecc", + "reference": "c1c2e997aa3146983ed888ad08b15470a2e22ecc", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2 || ~2.0" + "nikic/php-parser": "^4.6", + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.2.x-dev" + "dev-master": "1.0-dev" } }, "autoload": { @@ -1558,56 +2399,52 @@ "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" + "email": "sebastian@phpunit.de", + "role": "lead" } ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" + "description": "Library for counting the lines of code in PHP source code", + "homepage": "https://github.com/sebastianbergmann/lines-of-code", + "support": { + "issues": "https://github.com/sebastianbergmann/lines-of-code/issues", + "source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2017-01-29T09:50:25+00:00" + "time": "2020-11-28T06:42:11+00:00" }, { - "name": "sebastian/diff", - "version": "1.4.3", + "name": "sebastian/object-enumerator", + "version": "4.0.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", - "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/5c9eeac41b290a3712d88851518825ad78f45c71", + "reference": "5c9eeac41b290a3712d88851518825ad78f45c71", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": ">=7.3", + "sebastian/object-reflector": "^2.0", + "sebastian/recursion-context": "^4.0" }, "require-dev": { - "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1620,46 +2457,49 @@ "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" + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-enumerator/issues", + "source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2017-05-22T07:24:03+00:00" + "time": "2020-10-26T13:12:34+00:00" }, { - "name": "sebastian/environment", - "version": "1.3.8", + "name": "sebastian/object-reflector", + "version": "2.0.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea" + "url": "https://github.com/sebastianbergmann/object-reflector.git", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/be2c607e43ce4c89ecd60e75c6a85c126e754aea", - "reference": "be2c607e43ce4c89ecd60e75c6a85c126e754aea", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", + "reference": "b4f479ebdbf63ac605d183ece17d8d7fe49c15c7", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.0" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "2.0-dev" } }, "autoload": { @@ -1677,41 +2517,44 @@ "email": "sebastian@phpunit.de" } ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" + "description": "Allows reflection of object attributes, including inherited and non-public ones", + "homepage": "https://github.com/sebastianbergmann/object-reflector/", + "support": { + "issues": "https://github.com/sebastianbergmann/object-reflector/issues", + "source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2016-08-18T05:49:44+00:00" + "time": "2020-10-26T13:14:26+00:00" }, { - "name": "sebastian/exporter", - "version": "1.2.2", + "name": "sebastian/recursion-context", + "version": "4.0.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4" + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/42c4c2eec485ee3e159ec9884f95b431287edde4", - "reference": "42c4c2eec485ee3e159ec9884f95b431287edde4", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/cd9d8cf3c5804de4341c283ed787f099f5506172", + "reference": "cd9d8cf3c5804de4341c283ed787f099f5506172", "shasum": "" }, "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" + "php": ">=7.3" }, "require-dev": { - "ext-mbstring": "*", - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.3.x-dev" + "dev-master": "4.0-dev" } }, "autoload": { @@ -1724,62 +2567,57 @@ "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": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, { "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" + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "support": { + "issues": "https://github.com/sebastianbergmann/recursion-context/issues", + "source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2016-06-17T09:04:28+00:00" + "time": "2020-10-26T13:17:30+00:00" }, { - "name": "sebastian/global-state", - "version": "1.1.1", + "name": "sebastian/resource-operations", + "version": "3.0.3", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", + "reference": "0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" + "phpunit/phpunit": "^9.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "3.0-dev" } }, "autoload": { @@ -1797,37 +2635,44 @@ "email": "sebastian@phpunit.de" } ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "support": { + "issues": "https://github.com/sebastianbergmann/resource-operations/issues", + "source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } ], - "time": "2015-10-12T03:26:01+00:00" + "time": "2020-09-28T06:45:17+00:00" }, { - "name": "sebastian/recursion-context", - "version": "1.0.5", + "name": "sebastian/type", + "version": "2.3.4", "source": { "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7" + "url": "https://github.com/sebastianbergmann/type.git", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/b19cc3298482a335a95f3016d2f8a6950f0fbcd7", - "reference": "b19cc3298482a335a95f3016d2f8a6950f0fbcd7", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b8cd8a1c753c90bc1a0f5372170e3e489136f914", + "reference": "b8cd8a1c753c90bc1a0f5372170e3e489136f914", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.3" }, "require-dev": { - "phpunit/phpunit": "~4.4" + "phpunit/phpunit": "^9.3" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0.x-dev" + "dev-master": "2.3-dev" } }, "autoload": { @@ -1840,38 +2685,49 @@ "BSD-3-Clause" ], "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, { "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Collection of value objects that represent the types of the PHP type system", + "homepage": "https://github.com/sebastianbergmann/type", + "support": { + "issues": "https://github.com/sebastianbergmann/type/issues", + "source": "https://github.com/sebastianbergmann/type/tree/2.3.4" + }, + "funding": [ { - "name": "Adam Harvey", - "email": "aharvey@php.net" + "url": "https://github.com/sebastianbergmann", + "type": "github" } ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2016-10-03T07:41:43+00:00" + "time": "2021-06-15T12:49:02+00:00" }, { "name": "sebastian/version", - "version": "1.0.6", + "version": "3.0.2", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + "reference": "c6c1022351a901512170118436c764e473f6de8c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c", + "reference": "c6c1022351a901512170118436c764e473f6de8c", "shasum": "" }, + "require": { + "php": ">=7.3" + }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1890,7 +2746,17 @@ ], "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" + "support": { + "issues": "https://github.com/sebastianbergmann/version/issues", + "source": "https://github.com/sebastianbergmann/version/tree/3.0.2" + }, + "funding": [ + { + "url": "https://github.com/sebastianbergmann", + "type": "github" + } + ], + "time": "2020-09-28T06:39:44+00:00" }, { "name": "symfony/http-foundation", @@ -1945,24 +2811,27 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/http-foundation/tree/2.8" + }, "time": "2019-11-12T12:34:41+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.13.0", + "version": "v1.23.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", + "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-ctype": "For best performance" @@ -1970,7 +2839,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -2003,24 +2876,41 @@ "polyfill", "portable" ], - "time": "2019-11-27T13:56:44+00:00" + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-02-19T12:13:01+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.13.0", + "version": "v1.23.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", + "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-mbstring": "For best performance" @@ -2028,7 +2918,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -2062,41 +2956,51 @@ "portable", "shim" ], - "time": "2019-11-27T14:18:11+00:00" + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-05-27T12:26:48+00:00" }, { "name": "symfony/polyfill-php54", - "version": "v1.13.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php54.git", - "reference": "dd1618047426412036e98d159940d58a81fc392c" + "reference": "37285b1d5d13f37c8bee546d8d2ad0353460c4c7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/dd1618047426412036e98d159940d58a81fc392c", - "reference": "dd1618047426412036e98d159940d58a81fc392c", + "url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/37285b1d5d13f37c8bee546d8d2ad0353460c4c7", + "reference": "37285b1d5d13f37c8bee546d8d2ad0353460c4c7", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, - "type": "library", + "type": "metapackage", "extra": { "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php54\\": "" + "dev-main": "1.20-dev" }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2120,39 +3024,51 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "support": { + "source": "https://github.com/symfony/polyfill-php54/tree/v1.20.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-23T14:02:19+00:00" }, { "name": "symfony/polyfill-php55", - "version": "v1.13.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php55.git", - "reference": "b0d838f225725e2951af1aafc784d2e5ea7b656e" + "reference": "c17452124a883900e1d73961f9075a638399c1a0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/b0d838f225725e2951af1aafc784d2e5ea7b656e", - "reference": "b0d838f225725e2951af1aafc784d2e5ea7b656e", + "url": "https://api.github.com/repos/symfony/polyfill-php55/zipball/c17452124a883900e1d73961f9075a638399c1a0", + "reference": "c17452124a883900e1d73961f9075a638399c1a0", "shasum": "" }, "require": { - "ircmaxell/password-compat": "~1.0", - "php": ">=5.3.3" + "php": ">=7.1" }, - "type": "library", + "type": "metapackage", "extra": { "branch-alias": { - "dev-master": "1.13-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php55\\": "" + "dev-main": "1.20-dev" }, - "files": [ - "bootstrap.php" - ] + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2176,92 +3092,106 @@ "portable", "shim" ], - "time": "2019-11-27T13:56:44+00:00" + "support": { + "source": "https://github.com/symfony/polyfill-php55/tree/v1.20.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2020-10-23T14:02:19+00:00" }, { - "name": "symfony/yaml", - "version": "v3.4.35", + "name": "theseer/tokenizer", + "version": "1.2.1", "source": { "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "dab657db15207879217fc81df4f875947bf68804" + "url": "https://github.com/theseer/tokenizer.git", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/dab657db15207879217fc81df4f875947bf68804", - "reference": "dab657db15207879217fc81df4f875947bf68804", + "url": "https://api.github.com/repos/theseer/tokenizer/zipball/34a41e998c2183e22995f158c581e7b5e755ab9e", + "reference": "34a41e998c2183e22995f158c581e7b5e755ab9e", "shasum": "" }, "require": { - "php": "^5.5.9|>=7.0.8", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<3.4" - }, - "require-dev": { - "symfony/console": "~3.4|~4.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" + "ext-dom": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": "^7.2 || ^8.0" }, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.4-dev" - } - }, "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "src/" ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "MIT" + "BSD-3-Clause" ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, + "name": "Arne Blankerts", + "email": "arne@blankerts.de", + "role": "Developer" + } + ], + "description": "A small library for converting tokenized PHP source code into XML and potentially other formats", + "support": { + "issues": "https://github.com/theseer/tokenizer/issues", + "source": "https://github.com/theseer/tokenizer/tree/1.2.1" + }, + "funding": [ { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" + "url": "https://github.com/theseer", + "type": "github" } ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2019-10-24T15:33:53+00:00" + "time": "2021-07-28T10:34:58+00:00" }, { "name": "webmozart/assert", - "version": "1.6.0", + "version": "1.10.0", "source": { "type": "git", - "url": "https://github.com/webmozart/assert.git", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925" + "url": "https://github.com/webmozarts/assert.git", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozart/assert/zipball/573381c0a64f155a0d9a23f4b0c797194805b925", - "reference": "573381c0a64f155a0d9a23f4b0c797194805b925", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", + "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", "shasum": "" }, "require": { - "php": "^5.3.3 || ^7.0", + "php": "^7.2 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { - "vimeo/psalm": "<3.6.0" + "phpstan/phpstan": "<0.12.20", + "vimeo/psalm": "<4.6.1 || 4.6.2" }, "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13" + "phpunit/phpunit": "^8.5.13" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.10-dev" + } + }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -2283,7 +3213,11 @@ "check", "validate" ], - "time": "2019-11-24T13:36:37+00:00" + "support": { + "issues": "https://github.com/webmozarts/assert/issues", + "source": "https://github.com/webmozarts/assert/tree/1.10.0" + }, + "time": "2021-03-09T10:59:23+00:00" } ], "aliases": [], @@ -2293,5 +3227,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "1.1.0" + "plugin-api-version": "2.1.0" } From 746967503e27fb387de21de809232cc3fda0ab56 Mon Sep 17 00:00:00 2001 From: Josemar Lohn Date: Sat, 7 Aug 2021 04:50:11 -0300 Subject: [PATCH 02/12] Remove Facebook Test --- tests/FacebookTest.php | 75 ------------------------------------------ 1 file changed, 75 deletions(-) delete mode 100644 tests/FacebookTest.php diff --git a/tests/FacebookTest.php b/tests/FacebookTest.php deleted file mode 100644 index 37c0d49..0000000 --- a/tests/FacebookTest.php +++ /dev/null @@ -1,75 +0,0 @@ -client = new Parse(); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - - $result = $this->client->parse($request, $response); - $body = $result->getContent(); - $this->assertEquals(200, $result->getStatusCode()); - return json_decode($body, true); - } - - private function loadFbObject($id) { - return file_get_contents(dirname(__FILE__).'/data/graph.facebook.com/'.$id.'.json'); - } - - public function testFacebookEventWithHCard() { - $url = 'https://www.facebook.com/events/446197069049722/'; - $json = $this->loadFbObject('446197069049722'); - - $data = $this->parse(['url' => $url, 'body' => $json]); - - $this->assertArrayHasKey('code', $data); - $this->assertEquals('facebook', $data['source-format']); - - $this->assertEquals('event', $data['data']['type']); - $this->assertEquals('event', $data['data']['post-type']); - $this->assertEquals('IndieWeb Summit', $data['data']['name']); - $this->assertEquals('2017-06-24T09:00:00-0700', $data['data']['start']); - $this->assertEquals('2017-06-25T18:00:00-0700', $data['data']['end']); - $this->assertContains('The seventh annual gathering for independent web creators of all kinds,', $data['data']['summary']); - $this->assertEquals('https://facebook.com/332204056925945', $data['data']['location']); - - $card = $data['data']['refs'][0]; - $this->assertEquals('card', $card['type']); - $this->assertEquals('https://facebook.com/332204056925945', $card['url']); - $this->assertEquals('Mozilla PDX', $card['name']); - $this->assertEquals('97209', $card['postal-code']); - $this->assertEquals('Portland', $card['locality']); - $this->assertEquals('OR', $card['region']); - $this->assertEquals('1120 NW Couch St, Ste 320', $card['street-address']); - $this->assertEquals('United States', $card['country']); - $this->assertEquals('45.5233192', $card['latitude']); - $this->assertEquals('-122.6824722', $card['longitude']); - } - - public function testFacebookEvent() { - $url = 'https://www.facebook.com/events/1596554663924436/'; - $json = $this->loadFbObject('1596554663924436'); - - $data = $this->parse(['url' => $url, 'body' => $json]); - - $this->assertArrayHasKey('code', $data); - $this->assertEquals('facebook', $data['source-format']); - - $this->assertEquals('event', $data['data']['type']); - $this->assertEquals('event', $data['data']['post-type']); - $this->assertEquals('Homebrew Website Club', $data['data']['name']); - $this->assertEquals('2015-04-22T19:00:00-0400', $data['data']['start']); - $this->assertContains('Are you building your own website? Indie reader?', $data['data']['summary']); - $this->assertEquals('Charging Bull - WeeWork - 25 Broadway, New York, NY 10004', $data['data']['location']); - } - -} From 504f59555dd56b817feb0b382aa1238456f5bdec Mon Sep 17 00:00:00 2001 From: Josemar Lohn Date: Sat, 7 Aug 2021 04:50:45 -0300 Subject: [PATCH 03/12] Update all tests to support phpunit9 --- tests/ActivityStreamsTest.php | 465 +++--- tests/AuthorTest.php | 379 ++--- tests/FeedTest.php | 1016 +++++++------- tests/FetchTest.php | 415 +++--- tests/FetchTestDisabled.php | 49 +- tests/FindFeedsTest.php | 451 +++--- tests/GitHubTest.php | 256 ++-- tests/HackernewsTest.php | 111 +- tests/HelpersTest.php | 68 +- tests/InstagramTest.php | 610 ++++---- tests/LibraryTest.php | 107 +- tests/MediaTypeTest.php | 78 +- tests/ParseTest.php | 2494 +++++++++++++++++---------------- tests/SanitizeTest.php | 804 ++++++----- tests/TokenTest.php | 315 +++-- tests/TwitterTest.php | 606 ++++---- tests/bootstrap.php | 12 +- 17 files changed, 4300 insertions(+), 3936 deletions(-) diff --git a/tests/ActivityStreamsTest.php b/tests/ActivityStreamsTest.php index 81ab035..709abcb 100644 --- a/tests/ActivityStreamsTest.php +++ b/tests/ActivityStreamsTest.php @@ -2,230 +2,245 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class ActivityStreamsTest extends PHPUnit_Framework_TestCase { - - private $http; - - public function setUp() { - $this->client = new Parse(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->parse($request, $response); - } - - public function testAuthorProfile() { - $url = 'http://activitystreams.example/aaronpk'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('card', $data['data']['type']); - $this->assertEquals('aaronpk', $data['data']['name']); - $this->assertEquals('https://aaronparecki.com/images/profile.jpg', $data['data']['photo']); - $this->assertEquals('https://aaronparecki.com/', $data['data']['url']); - } - - public function testNoteWithTags() { - $url = 'http://activitystreams.example/note.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('note', $data['data']['post-type']); - $this->assertEquals($url, $data['data']['url']); - $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); - $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['content']['text']); - $this->assertArrayNotHasKey('html', $data['data']['content']); - $this->assertSame(['activitystreams'], $data['data']['category']); - $this->assertEquals('aaronpk', $data['data']['author']['name']); - $this->assertEquals('https://aaronparecki.com/images/profile.jpg', $data['data']['author']['photo']); - $this->assertEquals('https://aaronparecki.com/', $data['data']['author']['url']); - } - - public function testArticle() { - $url = 'http://activitystreams.example/article.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('article', $data['data']['post-type']); - $this->assertEquals($url, $data['data']['url']); - $this->assertEquals('An Article', $data['data']['name']); - $this->assertEquals('This is the content of an ActivityStreams article', $data['data']['content']['text']); - $this->assertEquals('

This is the content of an ActivityStreams article

', $data['data']['content']['html']); - $this->assertEquals('aaronpk', $data['data']['author']['name']); - $this->assertEquals('https://aaronparecki.com/images/profile.jpg', $data['data']['author']['photo']); - $this->assertEquals('https://aaronparecki.com/', $data['data']['author']['url']); - } - - public function testPhoto() { - $url = 'http://activitystreams.example/photo.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals($url, $data['data']['url']); - $this->assertEquals('photo', $data['data']['post-type']); - $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); - $this->assertEquals('This is the text content of an ActivityStreams photo', $data['data']['content']['text']); - $this->assertArrayNotHasKey('html', $data['data']['content']); - $this->assertSame(['activitystreams'], $data['data']['category']); - $this->assertSame(['https://aaronparecki.com/2018/06/28/26/photo.jpg'], $data['data']['photo']); - } - - public function testVideo() { - $url = 'http://activitystreams.example/video.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('video', $data['data']['post-type']); - $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); - $this->assertSame(['https://aaronparecki.com/2018/07/21/19/video.mp4'], $data['data']['video']); - } - - public function testReply() { - $url = 'http://activitystreams.example/reply.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('reply', $data['data']['post-type']); - $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); - $this->assertArrayNotHasKey('category', $data['data']); // should not include the person-tag - // For now, don't fetch the reply context - $this->assertEquals(['http://activitystreams.example/note.json'], $data['data']['in-reply-to']); - } - - public function testCustomEmoji() { - $url = 'http://activitystreams.example/custom-emoji.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('note', $data['data']['post-type']); - $this->assertEquals("https://mastodon.social/@Gargron/100465999501820229", $data['data']['url']); - $this->assertEquals('2018-07-30T22:24:54+00:00', $data['data']['published']); - $this->assertEquals(':yikes:', $data['data']['content']['text']); - $this->assertEquals('

:yikes:

', $data['data']['content']['html']); - $this->assertEquals('Eugen', $data['data']['author']['name']); - $this->assertEquals('Gargron', $data['data']['author']['nickname']); - $this->assertEquals('https://files.mastodon.social/accounts/avatars/000/000/001/original/eb9e00274b135808.png', $data['data']['author']['photo']); - $this->assertEquals('https://mastodon.social/@Gargron', $data['data']['author']['url']); - } - - public function testRelAlternatePriority() { - $url = 'http://source.example.com/rel-alternate-as2'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('http://activitystreams.example/note.json', $data['parsed-url']); - $this->assertEquals('http://source.example.com/rel-alternate-as2', $data['url']); - $this->assertEquals('note', $data['data']['post-type']); - $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); - $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['content']['text']); - $this->assertArrayNotHasKey('html', $data['data']['content']); - $this->assertSame(['activitystreams'], $data['data']['category']); - } - - public function testSensitiveContent() { - $url = 'http://activitystreams.example/sensitive.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('note', $data['data']['post-type']); - $this->assertEquals('sensitive topic', $data['data']['summary']); - $this->assertEquals('This is the text content of a sensitive ActivityStreams note', $data['data']['content']['text']); - $this->assertArrayNotHasKey('name', $data['data']); - } - - public function testRepost() { - $url = 'http://activitystreams.example/repost.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('repost', $data['data']['post-type']); - $this->assertArrayNotHasKey('content', $data['data']); - $this->assertArrayNotHasKey('name', $data['data']); - $this->assertEquals('Gargron', $data['data']['author']['nickname']); - $this->assertEquals(['http://activitystreams.example/note.json'], $data['data']['repost-of']); - $this->assertArrayHasKey('http://activitystreams.example/note.json', $data['data']['refs']); - $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['refs']['http://activitystreams.example/note.json']['content']['text']); - } - - public function testLike() { - $url = 'http://activitystreams.example/like.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('like', $data['data']['post-type']); - $this->assertArrayNotHasKey('content', $data['data']); - $this->assertArrayNotHasKey('name', $data['data']); - $this->assertEquals('Gargron', $data['data']['author']['nickname']); - $this->assertEquals(['http://activitystreams.example/note.json'], $data['data']['like-of']); - $this->assertArrayHasKey('http://activitystreams.example/note.json', $data['data']['refs']); - $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['refs']['http://activitystreams.example/note.json']['content']['text']); - } - - public function testNoteWrappedInCreate() { - $url = 'http://activitystreams.example/create.json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('activity+json', $data['source-format']); - $this->assertEquals('reply', $data['data']['post-type']); - $this->assertEquals('https://toot.cat/@jamey/100471682482196371', $data['data']['url']); - $this->assertEquals('2018-07-31T22:30:09+00:00', $data['data']['published']); - $this->assertEquals('@darius Huh, I just have never encountered anyone using the phrase generically like that.But you might consider writing IndieWeb.org-style bots (Atom+WebSub, and optionally WebMention if you want them to be interactive), and then using https://fed.brid.gy/ as an alternative to implementing ActivityPub yourself...', $data['data']['content']['text']); - $this->assertEquals('https://social.tinysubversions.com/users/darius/statuses/100471614681787834', $data['data']['in-reply-to'][0]); - $this->assertEquals('Jamey Sharp', $data['data']['author']['name']); - $this->assertEquals('https://s3-us-west-2.amazonaws.com/tootcatapril2017/accounts/avatars/000/013/259/original/c904452a8411e4f5.jpg', $data['data']['author']['photo']); - $this->assertEquals('https://toot.cat/@jamey', $data['data']['author']['url']); - } +class ActivityStreamsTest extends PHPUnit\Framework\TestCase +{ + + private $http; + + public function setUp(): void + { + $this->client = new Parse(); + $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); + $this->client->mc = null; + } + + private function parse($params) + { + $request = new Request($params); + $response = new Response(); + return $this->client->parse($request, $response); + } + + public function testAuthorProfile() + { + $url = 'http://activitystreams.example/aaronpk'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('card', $data['data']['type']); + $this->assertEquals('aaronpk', $data['data']['name']); + $this->assertEquals('https://aaronparecki.com/images/profile.jpg', $data['data']['photo']); + $this->assertEquals('https://aaronparecki.com/', $data['data']['url']); + } + + public function testNoteWithTags() + { + $url = 'http://activitystreams.example/note.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('note', $data['data']['post-type']); + $this->assertEquals($url, $data['data']['url']); + $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); + $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['content']['text']); + $this->assertArrayNotHasKey('html', $data['data']['content']); + $this->assertSame(['activitystreams'], $data['data']['category']); + $this->assertEquals('aaronpk', $data['data']['author']['name']); + $this->assertEquals('https://aaronparecki.com/images/profile.jpg', $data['data']['author']['photo']); + $this->assertEquals('https://aaronparecki.com/', $data['data']['author']['url']); + } + + public function testArticle() + { + $url = 'http://activitystreams.example/article.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('article', $data['data']['post-type']); + $this->assertEquals($url, $data['data']['url']); + $this->assertEquals('An Article', $data['data']['name']); + $this->assertEquals('This is the content of an ActivityStreams article', $data['data']['content']['text']); + $this->assertEquals('

This is the content of an ActivityStreams article

', $data['data']['content']['html']); + $this->assertEquals('aaronpk', $data['data']['author']['name']); + $this->assertEquals('https://aaronparecki.com/images/profile.jpg', $data['data']['author']['photo']); + $this->assertEquals('https://aaronparecki.com/', $data['data']['author']['url']); + } + + public function testPhoto() + { + $url = 'http://activitystreams.example/photo.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals($url, $data['data']['url']); + $this->assertEquals('photo', $data['data']['post-type']); + $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); + $this->assertEquals('This is the text content of an ActivityStreams photo', $data['data']['content']['text']); + $this->assertArrayNotHasKey('html', $data['data']['content']); + $this->assertSame(['activitystreams'], $data['data']['category']); + $this->assertSame(['https://aaronparecki.com/2018/06/28/26/photo.jpg'], $data['data']['photo']); + } + + public function testVideo() + { + $url = 'http://activitystreams.example/video.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('video', $data['data']['post-type']); + $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); + $this->assertSame(['https://aaronparecki.com/2018/07/21/19/video.mp4'], $data['data']['video']); + } + + public function testReply() + { + $url = 'http://activitystreams.example/reply.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('reply', $data['data']['post-type']); + $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); + $this->assertArrayNotHasKey('category', $data['data']); // should not include the person-tag + // For now, don't fetch the reply context + $this->assertEquals(['http://activitystreams.example/note.json'], $data['data']['in-reply-to']); + } + + public function testCustomEmoji() + { + $url = 'http://activitystreams.example/custom-emoji.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('note', $data['data']['post-type']); + $this->assertEquals("https://mastodon.social/@Gargron/100465999501820229", $data['data']['url']); + $this->assertEquals('2018-07-30T22:24:54+00:00', $data['data']['published']); + $this->assertEquals(':yikes:', $data['data']['content']['text']); + $this->assertEquals('

:yikes:

', $data['data']['content']['html']); + $this->assertEquals('Eugen', $data['data']['author']['name']); + $this->assertEquals('Gargron', $data['data']['author']['nickname']); + $this->assertEquals('https://files.mastodon.social/accounts/avatars/000/000/001/original/eb9e00274b135808.png', $data['data']['author']['photo']); + $this->assertEquals('https://mastodon.social/@Gargron', $data['data']['author']['url']); + } + + public function testRelAlternatePriority() + { + $url = 'http://source.example.com/rel-alternate-as2'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('http://activitystreams.example/note.json', $data['parsed-url']); + $this->assertEquals('http://source.example.com/rel-alternate-as2', $data['url']); + $this->assertEquals('note', $data['data']['post-type']); + $this->assertEquals('2018-07-12T13:02:04-07:00', $data['data']['published']); + $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['content']['text']); + $this->assertArrayNotHasKey('html', $data['data']['content']); + $this->assertSame(['activitystreams'], $data['data']['category']); + } + + public function testSensitiveContent() + { + $url = 'http://activitystreams.example/sensitive.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('note', $data['data']['post-type']); + $this->assertEquals('sensitive topic', $data['data']['summary']); + $this->assertEquals('This is the text content of a sensitive ActivityStreams note', $data['data']['content']['text']); + $this->assertArrayNotHasKey('name', $data['data']); + } + + public function testRepost() + { + $url = 'http://activitystreams.example/repost.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('repost', $data['data']['post-type']); + $this->assertArrayNotHasKey('content', $data['data']); + $this->assertArrayNotHasKey('name', $data['data']); + $this->assertEquals('Gargron', $data['data']['author']['nickname']); + $this->assertEquals(['http://activitystreams.example/note.json'], $data['data']['repost-of']); + $this->assertArrayHasKey('http://activitystreams.example/note.json', $data['data']['refs']); + $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['refs']['http://activitystreams.example/note.json']['content']['text']); + } + + public function testLike() + { + $url = 'http://activitystreams.example/like.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('like', $data['data']['post-type']); + $this->assertArrayNotHasKey('content', $data['data']); + $this->assertArrayNotHasKey('name', $data['data']); + $this->assertEquals('Gargron', $data['data']['author']['nickname']); + $this->assertEquals(['http://activitystreams.example/note.json'], $data['data']['like-of']); + $this->assertArrayHasKey('http://activitystreams.example/note.json', $data['data']['refs']); + $this->assertEquals('This is the text content of an ActivityStreams note', $data['data']['refs']['http://activitystreams.example/note.json']['content']['text']); + } + + public function testNoteWrappedInCreate() + { + $url = 'http://activitystreams.example/create.json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('activity+json', $data['source-format']); + $this->assertEquals('reply', $data['data']['post-type']); + $this->assertEquals('https://toot.cat/@jamey/100471682482196371', $data['data']['url']); + $this->assertEquals('2018-07-31T22:30:09+00:00', $data['data']['published']); + $this->assertEquals('@darius Huh, I just have never encountered anyone using the phrase generically like that.But you might consider writing IndieWeb.org-style bots (Atom+WebSub, and optionally WebMention if you want them to be interactive), and then using https://fed.brid.gy/ as an alternative to implementing ActivityPub yourself...', $data['data']['content']['text']); + $this->assertEquals('https://social.tinysubversions.com/users/darius/statuses/100471614681787834', $data['data']['in-reply-to'][0]); + $this->assertEquals('Jamey Sharp', $data['data']['author']['name']); + $this->assertEquals('https://s3-us-west-2.amazonaws.com/tootcatapril2017/accounts/avatars/000/013/259/original/c904452a8411e4f5.jpg', $data['data']['author']['photo']); + $this->assertEquals('https://toot.cat/@jamey', $data['data']['author']['url']); + } } diff --git a/tests/AuthorTest.php b/tests/AuthorTest.php index b40eee6..2432f60 100644 --- a/tests/AuthorTest.php +++ b/tests/AuthorTest.php @@ -2,186 +2,201 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class AuthorTest extends PHPUnit_Framework_TestCase { - - private $http; - - public function setUp() { - $this->client = new Parse(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->parse($request, $response); - } - - public function testHEntryAuthorIsName() { - $url = 'http://author.example.com/h-entry-author-is-name'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertEmpty($data->data->author->url); - $this->assertEquals('Author Name', $data->data->author->name); - $this->assertEmpty($data->data->author->photo); - } - - public function testHEntryAuthorIsRelLinkToHCardOnPage() { - $url = 'http://author.example.com/h-entry-author-is-rel-link-to-h-card-on-page'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('http://author.example.com/about', $data->data->author->url); - $this->assertEquals('Author', $data->data->author->name); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); - } - - public function testHEntryAuthorIsRelLinkToHCardWithRelMe() { - $url = 'http://author.example.com/h-entry-author-is-rel-link-to-h-card-with-rel-me'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('http://author.example.com/about-rel-me', $data->data->author->url); - $this->assertEquals('Author Full Name', $data->data->author->name); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); - } - - public function testHEntryAuthorIsRelLinkToHCardWithUrlUid() { - $url = 'http://author.example.com/h-entry-author-is-rel-link-to-h-card-with-url-uid'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('http://author.example.com/about-url-uid', $data->data->author->url); - $this->assertEquals('Author Full Name', $data->data->author->name); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); - } - - public function testHEntryAuthorIsUrlToHCardOnPage() { - $url = 'http://author.example.com/h-entry-author-is-url-to-h-card-on-page'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('http://author.example.com/about', $data->data->author->url); - $this->assertEquals('Author', $data->data->author->name); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); - } - - public function testHEntryAuthorIsUrlToHCardWithMultipleLinks() { - $url = 'http://author.example.com/h-entry-author-is-url-to-h-card-with-multiple-links'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('http://author.example.com/about-with-multiple-urls', $data->data->author->url); - $this->assertEquals('Author Full Name', $data->data->author->name); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); - } - - public function testHEntryAuthorIsUrlToHCardWithNoURL() { - $url = 'http://author.example.com/h-entry-author-is-url-to-h-card-with-no-url'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('http://author.example.com/about-no-url', $data->data->author->url); - $this->assertEquals('Author Full Name', $data->data->author->name); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); - } - - public function testHEntryHasHCardAndUrlAuthor() { - $url = 'http://author.example.com/h-entry-has-h-card-and-url-author'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('http://author.example.com/about', $data->data->author->url); - $this->assertEquals('Author', $data->data->author->name); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); - } - - public function testHEntryHasHCardAuthor() { - $url = 'http://author.example.com/h-entry-has-h-card-author'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('http://author.example.com/about', $data->data->author->url); - $this->assertEquals('Author', $data->data->author->name); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); - } - - public function testPageIsHCard() { - $url = 'http://author.example.com/about'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('card', $data->data->type); - $this->assertEquals('http://author.example.com/about', $data->data->url); - $this->assertEquals('Author Full Name', $data->data->name); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->photo); - } - - public function testPageIsHCardWithNoURL() { - $url = 'http://author.example.com/about-no-url'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('card', $data->data->type); - $this->assertEquals('Author Full Name', $data->data->name); - $this->assertEquals($url, $data->data->url); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->photo); - } - - public function testHEntryAuthorIs0() { - $url = 'http://author.example.com/author-name-is-0'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - - $this->assertEquals('card', $data->data->type); - $this->assertEquals('http://author.example.com/photo.jpg', $data->data->photo); - $this->assertEquals('0', $data->data->name); - } - - /* - public function testHFeedHasHCardAuthor() { +class AuthorTest extends PHPUnit\Framework\TestCase +{ + + private $http; + + public function setUp(): void + { + $this->client = new Parse(); + $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); + $this->client->mc = null; + } + + private function parse($params) + { + $request = new Request($params); + $response = new Response(); + return $this->client->parse($request, $response); + } + + public function testHEntryAuthorIsName() + { + $url = 'http://author.example.com/h-entry-author-is-name'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertEmpty($data->data->author->url); + $this->assertEquals('Author Name', $data->data->author->name); + $this->assertEmpty($data->data->author->photo); + } + + public function testHEntryAuthorIsRelLinkToHCardOnPage() + { + $url = 'http://author.example.com/h-entry-author-is-rel-link-to-h-card-on-page'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('http://author.example.com/about', $data->data->author->url); + $this->assertEquals('Author', $data->data->author->name); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); + } + + public function testHEntryAuthorIsRelLinkToHCardWithRelMe() + { + $url = 'http://author.example.com/h-entry-author-is-rel-link-to-h-card-with-rel-me'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('http://author.example.com/about-rel-me', $data->data->author->url); + $this->assertEquals('Author Full Name', $data->data->author->name); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); + } + + public function testHEntryAuthorIsRelLinkToHCardWithUrlUid() + { + $url = 'http://author.example.com/h-entry-author-is-rel-link-to-h-card-with-url-uid'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('http://author.example.com/about-url-uid', $data->data->author->url); + $this->assertEquals('Author Full Name', $data->data->author->name); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); + } + + public function testHEntryAuthorIsUrlToHCardOnPage() + { + $url = 'http://author.example.com/h-entry-author-is-url-to-h-card-on-page'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('http://author.example.com/about', $data->data->author->url); + $this->assertEquals('Author', $data->data->author->name); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); + } + + public function testHEntryAuthorIsUrlToHCardWithMultipleLinks() + { + $url = 'http://author.example.com/h-entry-author-is-url-to-h-card-with-multiple-links'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('http://author.example.com/about-with-multiple-urls', $data->data->author->url); + $this->assertEquals('Author Full Name', $data->data->author->name); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); + } + + public function testHEntryAuthorIsUrlToHCardWithNoURL() + { + $url = 'http://author.example.com/h-entry-author-is-url-to-h-card-with-no-url'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('http://author.example.com/about-no-url', $data->data->author->url); + $this->assertEquals('Author Full Name', $data->data->author->name); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); + } + + public function testHEntryHasHCardAndUrlAuthor() + { + $url = 'http://author.example.com/h-entry-has-h-card-and-url-author'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('http://author.example.com/about', $data->data->author->url); + $this->assertEquals('Author', $data->data->author->name); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); + } + + public function testHEntryHasHCardAuthor() + { + $url = 'http://author.example.com/h-entry-has-h-card-author'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('http://author.example.com/about', $data->data->author->url); + $this->assertEquals('Author', $data->data->author->name); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); + } + + public function testPageIsHCard() + { + $url = 'http://author.example.com/about'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('card', $data->data->type); + $this->assertEquals('http://author.example.com/about', $data->data->url); + $this->assertEquals('Author Full Name', $data->data->name); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->photo); + } + + public function testPageIsHCardWithNoURL() + { + $url = 'http://author.example.com/about-no-url'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('card', $data->data->type); + $this->assertEquals('Author Full Name', $data->data->name); + $this->assertEquals($url, $data->data->url); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->photo); + } + + public function testHEntryAuthorIs0() + { + $url = 'http://author.example.com/author-name-is-0'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + + $this->assertEquals('card', $data->data->type); + $this->assertEquals('http://author.example.com/photo.jpg', $data->data->photo); + $this->assertEquals('0', $data->data->name); + } + + /* + public function testHFeedHasHCardAuthor() { $url = 'http://author.example.com/h-feed-has-h-card-author'; $response = $this->parse(['url' => $url]); @@ -192,7 +207,7 @@ class AuthorTest extends PHPUnit_Framework_TestCase { $this->assertEquals('http://author.example.com/about', $data->data->author->url); $this->assertEquals('Author', $data->data->author->name); $this->assertEquals('http://author.example.com/photo.jpg', $data->data->author->photo); - } - */ + } + */ } diff --git a/tests/FeedTest.php b/tests/FeedTest.php index b6f49d6..b04e2a0 100644 --- a/tests/FeedTest.php +++ b/tests/FeedTest.php @@ -2,505 +2,535 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class FeedTest extends PHPUnit_Framework_TestCase { - - private $http; - - public function setUp() { - $this->client = new Parse(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->parse($request, $response); - } - - public function testListOfHEntrys() { - $url = 'http://feed.example.com/list-of-hentrys'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals('feed', $data->type); - $this->assertEquals(4, count($data->items)); - $this->assertEquals('One', $data->items[0]->name); - $this->assertEquals('article', $data->items[0]->{'post-type'}); - $this->assertEquals('Two', $data->items[1]->name); - $this->assertEquals('article', $data->items[1]->{'post-type'}); - $this->assertEquals('Three', $data->items[2]->name); - $this->assertEquals('Four', $data->items[3]->name); - } - - public function testListOfHEntrysWithHCard() { - $url = 'http://feed.example.com/list-of-hentrys-with-h-card'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals('feed', $data->type); - $this->assertEquals(4, count($data->items)); - $this->assertEquals('One', $data->items[0]->name); - $this->assertEquals('article', $data->items[0]->{'post-type'}); - $this->assertEquals('Two', $data->items[1]->name); - $this->assertEquals('Three', $data->items[2]->name); - $this->assertEquals('Four', $data->items[3]->name); - - // Check that the author h-card was matched up with each h-entry - $this->assertEquals('Author Name', $data->items[0]->author->name); - $this->assertEquals('Author Name', $data->items[1]->author->name); - $this->assertEquals('Author Name', $data->items[2]->author->name); - $this->assertEquals('Author Name', $data->items[3]->author->name); - } - - public function testListOfHEntrysWithHCardNoExpect() { - $url = 'http://feed.example.com/list-of-hentrys-with-h-card'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - - $this->assertEquals('feed', $data->type); - $this->assertEquals(4, count($data->items)); - $this->assertEquals('One', $data->items[0]->name); - $this->assertEquals('article', $data->items[0]->{'post-type'}); - $this->assertEquals('Two', $data->items[1]->name); - $this->assertEquals('Three', $data->items[2]->name); - $this->assertEquals('Four', $data->items[3]->name); - - // Check that the author h-card was matched up with each h-entry - $this->assertEquals('Author Name', $data->items[0]->author->name); - $this->assertEquals('Author Name', $data->items[1]->author->name); - $this->assertEquals('Author Name', $data->items[2]->author->name); - $this->assertEquals('Author Name', $data->items[3]->author->name); - } - - public function testShortListOfHEntrysWithHCardNoExpect() { - $url = 'http://feed.example.com/short-list-of-hentrys-with-h-card'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - - // In this case, this looks like a page permalink - $this->assertEquals('entry', $data->type); - // This test should find the h-entry rather than the h-card, because the h-card does not contain the page URL - $this->assertEquals('http://feed.example.com/1', $data->url); - $this->assertEquals('Author', $data->author->name); - } - - public function testShortListOfHEntrysWithHCard() { - $url = 'http://feed.example.com/short-list-of-hentrys-with-h-card'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals('feed', $data->type); - // This test should find the h-entry rather than the h-card, because expect=feed - $this->assertEquals('entry', $data->items[0]->type); - $this->assertEquals('http://feed.example.com/1', $data->items[0]->url); - $this->assertEquals('Author', $data->items[0]->author->name); - } - - public function testTopLevelHFeed() { - $url = 'http://feed.example.com/top-level-h-feed'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals('feed', $data->type); - $this->assertEquals(4, count($data->items)); - $this->assertEquals('One', $data->items[0]->name); - $this->assertEquals('Two', $data->items[1]->name); - $this->assertEquals('Three', $data->items[2]->name); - $this->assertEquals('Four', $data->items[3]->name); - } - - public function testTopLevelHFeedWithChildAuthor() { - $url = 'http://feed.example.com/h-feed-with-child-author'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals('feed', $data->type); - $this->assertEquals(4, count($data->items)); - $this->assertEquals('One', $data->items[0]->name); - $this->assertEquals('Two', $data->items[1]->name); - $this->assertEquals('Three', $data->items[2]->name); - $this->assertEquals('Four', $data->items[3]->name); - $this->assertEquals('Author Name', $data->items[0]->author->name); - $this->assertEquals('Author Name', $data->items[1]->author->name); - $this->assertEquals('Author Name', $data->items[2]->author->name); - $this->assertEquals('Author Name', $data->items[3]->author->name); - } - - public function testHCardWithChildHEntrys() { - $url = 'http://feed.example.com/h-card-with-child-h-entrys'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals('feed', $data->type); - $this->assertEquals(4, count($data->items)); - $this->assertEquals('One', $data->items[0]->name); - $this->assertEquals('Two', $data->items[1]->name); - $this->assertEquals('Three', $data->items[2]->name); - $this->assertEquals('Four', $data->items[3]->name); - } - - public function testHCardWithSiblingHEntrys() { - $url = 'http://feed.example.com/h-card-with-sibling-h-entrys'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals('feed', $data->type); - $this->assertEquals(4, count($data->items)); - $this->assertEquals('One', $data->items[0]->name); - $this->assertEquals('Two', $data->items[1]->name); - $this->assertEquals('Three', $data->items[2]->name); - $this->assertEquals('Four', $data->items[3]->name); - // Check that the author h-card was matched up with each h-entry - $this->assertEquals('Author Name', $data->items[0]->author->name); - $this->assertEquals('Author Name', $data->items[1]->author->name); - $this->assertEquals('Author Name', $data->items[2]->author->name); - $this->assertEquals('Author Name', $data->items[3]->author->name); - } - - public function testHCardWithChildHFeed() { - $url = 'http://feed.example.com/h-card-with-child-h-feed'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals('feed', $data->type); - $this->assertEquals(4, count($data->items)); - $this->assertEquals('One', $data->items[0]->name); - $this->assertEquals('Two', $data->items[1]->name); - $this->assertEquals('Three', $data->items[2]->name); - $this->assertEquals('Four', $data->items[3]->name); - // Check that the author h-card was matched up with each h-entry - $this->assertEquals('Author Name', $data->items[0]->author->name); - $this->assertEquals('Author Name', $data->items[1]->author->name); - $this->assertEquals('Author Name', $data->items[2]->author->name); - $this->assertEquals('Author Name', $data->items[3]->author->name); - } - - public function testHCardWithChildHFeedNoExpect() { - $url = 'http://feed.example.com/h-card-with-child-h-feed'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('mf2+html', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals('card', $data->type); - $this->assertEquals('Author Name', $data->name); - } - - public function testJSONFeed() { - $url = 'http://feed.example.com/jsonfeed'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('feed+json', $result->{'source-format'}); - $data = $result->data; - - $this->assertEquals(11, count($data->items)); - for($i=0; $i<8; $i++) { - $this->assertEquals('entry', $data->items[$i]->type); - $this->assertEquals('manton', $data->items[$i]->author->name); - $this->assertEquals('http://www.manton.org', $data->items[$i]->author->url); - $this->assertNotEmpty($data->items[$i]->url); - $this->assertNotEmpty($data->items[$i]->uid); - $this->assertNotEmpty($data->items[$i]->published); - $this->assertNotEmpty($data->items[$i]->content->html); - $this->assertNotEmpty($data->items[$i]->content->text); +class FeedTest extends PHPUnit\Framework\TestCase +{ + + private $http; + + public function setUp(): void + { + $this->client = new Parse(); + $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); + $this->client->mc = null; + } + + private function parse($params) + { + $request = new Request($params); + $response = new Response(); + return $this->client->parse($request, $response); + } + + public function testListOfHEntrys() + { + $url = 'http://feed.example.com/list-of-hentrys'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals('feed', $data->type); + $this->assertEquals(4, count($data->items)); + $this->assertEquals('One', $data->items[0]->name); + $this->assertEquals('article', $data->items[0]->{'post-type'}); + $this->assertEquals('Two', $data->items[1]->name); + $this->assertEquals('article', $data->items[1]->{'post-type'}); + $this->assertEquals('Three', $data->items[2]->name); + $this->assertEquals('Four', $data->items[3]->name); + } + + public function testListOfHEntrysWithHCard() + { + $url = 'http://feed.example.com/list-of-hentrys-with-h-card'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals('feed', $data->type); + $this->assertEquals(4, count($data->items)); + $this->assertEquals('One', $data->items[0]->name); + $this->assertEquals('article', $data->items[0]->{'post-type'}); + $this->assertEquals('Two', $data->items[1]->name); + $this->assertEquals('Three', $data->items[2]->name); + $this->assertEquals('Four', $data->items[3]->name); + + // Check that the author h-card was matched up with each h-entry + $this->assertEquals('Author Name', $data->items[0]->author->name); + $this->assertEquals('Author Name', $data->items[1]->author->name); + $this->assertEquals('Author Name', $data->items[2]->author->name); + $this->assertEquals('Author Name', $data->items[3]->author->name); + } + + public function testListOfHEntrysWithHCardNoExpect() + { + $url = 'http://feed.example.com/list-of-hentrys-with-h-card'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + + $this->assertEquals('feed', $data->type); + $this->assertEquals(4, count($data->items)); + $this->assertEquals('One', $data->items[0]->name); + $this->assertEquals('article', $data->items[0]->{'post-type'}); + $this->assertEquals('Two', $data->items[1]->name); + $this->assertEquals('Three', $data->items[2]->name); + $this->assertEquals('Four', $data->items[3]->name); + + // Check that the author h-card was matched up with each h-entry + $this->assertEquals('Author Name', $data->items[0]->author->name); + $this->assertEquals('Author Name', $data->items[1]->author->name); + $this->assertEquals('Author Name', $data->items[2]->author->name); + $this->assertEquals('Author Name', $data->items[3]->author->name); + } + + public function testShortListOfHEntrysWithHCardNoExpect() + { + $url = 'http://feed.example.com/short-list-of-hentrys-with-h-card'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + + // In this case, this looks like a page permalink + $this->assertEquals('entry', $data->type); + // This test should find the h-entry rather than the h-card, because the h-card does not contain the page URL + $this->assertEquals('http://feed.example.com/1', $data->url); + $this->assertEquals('Author', $data->author->name); + } + + public function testShortListOfHEntrysWithHCard() + { + $url = 'http://feed.example.com/short-list-of-hentrys-with-h-card'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals('feed', $data->type); + // This test should find the h-entry rather than the h-card, because expect=feed + $this->assertEquals('entry', $data->items[0]->type); + $this->assertEquals('http://feed.example.com/1', $data->items[0]->url); + $this->assertEquals('Author', $data->items[0]->author->name); + } + + public function testTopLevelHFeed() + { + $url = 'http://feed.example.com/top-level-h-feed'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals('feed', $data->type); + $this->assertEquals(4, count($data->items)); + $this->assertEquals('One', $data->items[0]->name); + $this->assertEquals('Two', $data->items[1]->name); + $this->assertEquals('Three', $data->items[2]->name); + $this->assertEquals('Four', $data->items[3]->name); + } + + public function testTopLevelHFeedWithChildAuthor() + { + $url = 'http://feed.example.com/h-feed-with-child-author'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals('feed', $data->type); + $this->assertEquals(4, count($data->items)); + $this->assertEquals('One', $data->items[0]->name); + $this->assertEquals('Two', $data->items[1]->name); + $this->assertEquals('Three', $data->items[2]->name); + $this->assertEquals('Four', $data->items[3]->name); + $this->assertEquals('Author Name', $data->items[0]->author->name); + $this->assertEquals('Author Name', $data->items[1]->author->name); + $this->assertEquals('Author Name', $data->items[2]->author->name); + $this->assertEquals('Author Name', $data->items[3]->author->name); + } + + public function testHCardWithChildHEntrys() + { + $url = 'http://feed.example.com/h-card-with-child-h-entrys'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals('feed', $data->type); + $this->assertEquals(4, count($data->items)); + $this->assertEquals('One', $data->items[0]->name); + $this->assertEquals('Two', $data->items[1]->name); + $this->assertEquals('Three', $data->items[2]->name); + $this->assertEquals('Four', $data->items[3]->name); + } + + public function testHCardWithSiblingHEntrys() + { + $url = 'http://feed.example.com/h-card-with-sibling-h-entrys'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals('feed', $data->type); + $this->assertEquals(4, count($data->items)); + $this->assertEquals('One', $data->items[0]->name); + $this->assertEquals('Two', $data->items[1]->name); + $this->assertEquals('Three', $data->items[2]->name); + $this->assertEquals('Four', $data->items[3]->name); + // Check that the author h-card was matched up with each h-entry + $this->assertEquals('Author Name', $data->items[0]->author->name); + $this->assertEquals('Author Name', $data->items[1]->author->name); + $this->assertEquals('Author Name', $data->items[2]->author->name); + $this->assertEquals('Author Name', $data->items[3]->author->name); + } + + public function testHCardWithChildHFeed() + { + $url = 'http://feed.example.com/h-card-with-child-h-feed'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals('feed', $data->type); + $this->assertEquals(4, count($data->items)); + $this->assertEquals('One', $data->items[0]->name); + $this->assertEquals('Two', $data->items[1]->name); + $this->assertEquals('Three', $data->items[2]->name); + $this->assertEquals('Four', $data->items[3]->name); + // Check that the author h-card was matched up with each h-entry + $this->assertEquals('Author Name', $data->items[0]->author->name); + $this->assertEquals('Author Name', $data->items[1]->author->name); + $this->assertEquals('Author Name', $data->items[2]->author->name); + $this->assertEquals('Author Name', $data->items[3]->author->name); + } + + public function testHCardWithChildHFeedNoExpect() + { + $url = 'http://feed.example.com/h-card-with-child-h-feed'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('mf2+html', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals('card', $data->type); + $this->assertEquals('Author Name', $data->name); + } + + public function testJSONFeed() + { + $url = 'http://feed.example.com/jsonfeed'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('feed+json', $result->{'source-format'}); + $data = $result->data; + + $this->assertEquals(11, count($data->items)); + for($i=0; $i<8; $i++) { + $this->assertEquals('entry', $data->items[$i]->type); + $this->assertEquals('manton', $data->items[$i]->author->name); + $this->assertEquals('http://www.manton.org', $data->items[$i]->author->url); + $this->assertNotEmpty($data->items[$i]->url); + $this->assertNotEmpty($data->items[$i]->uid); + $this->assertNotEmpty($data->items[$i]->published); + $this->assertNotEmpty($data->items[$i]->content->html); + $this->assertNotEmpty($data->items[$i]->content->text); + } + $this->assertEquals('note', $data->items[0]->{'post-type'}); + $this->assertEquals('article', $data->items[4]->{'post-type'}); + + $this->assertEquals('

Coming up on a year since I wrote about how today’s social networks are broken. Still what I believe.

', $data->items[7]->content->html); + $this->assertEquals('Coming up on a year since I wrote about how today’s social networks are broken. Still what I believe.', $data->items[7]->content->text); + $this->assertEquals('http://www.manton.org/2017/11/5979.html', $data->items[7]->url); + $this->assertEquals('http://www.manton.org/2017/11/5979.html', $data->items[7]->uid); + $this->assertEquals('2017-11-07T21:00:42+00:00', $data->items[7]->published); + + $this->assertEquals('feed', $data->type); + } + + public function testJSONFeedFallbackAuthor() + { + $url = 'http://feed.example.com/jsonfeed-author'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('feed+json', $result->{'source-format'}); + $data = $result->data; + + $this->assertEquals(11, count($data->items)); + for($i=0; $i<8; $i++) { + $this->assertEquals('entry', $data->items[$i]->type); + $this->assertEquals('Manton Reece', $data->items[$i]->author->name); + $this->assertEquals('https://www.manton.org/', $data->items[$i]->author->url); + $this->assertEquals('https://micro.blog/manton/avatar.jpg', $data->items[$i]->author->photo); + } + } + + public function testJSONFeedRelativeImages() + { + $url = 'http://feed.example.com/jsonfeed'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('feed+json', $result->{'source-format'}); + $data = $result->data; + + // Relative image on an item that has a url + $this->assertEquals('http://www.manton.org/2017/11/image.jpg', $data->items[9]->photo[0]); + + // Relative image on an item that has no URL, fall back to feed URL + $this->assertEquals('http://feed.example.com/image.jpg', $data->items[10]->photo[0]); + + // Relative image inside the content html + $this->assertStringContainsString('http://www.manton.org/2017/11/img.jpg', $data->items[9]->content->html); } - $this->assertEquals('note', $data->items[0]->{'post-type'}); - $this->assertEquals('article', $data->items[4]->{'post-type'}); - - $this->assertEquals('

Coming up on a year since I wrote about how today’s social networks are broken. Still what I believe.

', $data->items[7]->content->html); - $this->assertEquals('Coming up on a year since I wrote about how today’s social networks are broken. Still what I believe.', $data->items[7]->content->text); - $this->assertEquals('http://www.manton.org/2017/11/5979.html', $data->items[7]->url); - $this->assertEquals('http://www.manton.org/2017/11/5979.html', $data->items[7]->uid); - $this->assertEquals('2017-11-07T21:00:42+00:00', $data->items[7]->published); - - $this->assertEquals('feed', $data->type); - } - - public function testJSONFeedFallbackAuthor() { - $url = 'http://feed.example.com/jsonfeed-author'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('feed+json', $result->{'source-format'}); - $data = $result->data; - - $this->assertEquals(11, count($data->items)); - for($i=0; $i<8; $i++) { - $this->assertEquals('entry', $data->items[$i]->type); - $this->assertEquals('Manton Reece', $data->items[$i]->author->name); - $this->assertEquals('https://www.manton.org/', $data->items[$i]->author->url); - $this->assertEquals('https://micro.blog/manton/avatar.jpg', $data->items[$i]->author->photo); + + public function testAtomFeed() + { + $url = 'http://feed.example.com/atom'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('xml', $result->{'source-format'}); + $data = $result->data; + + $this->assertEquals(8, count($data->items)); + for($i=0; $i<8; $i++) { + $this->assertEquals('entry', $data->items[$i]->type); + $this->assertEquals('note', $data->items[$i]->{'post-type'}); + $this->assertEquals('Tantek', $data->items[$i]->author->name); + $this->assertEquals('http://tantek.com/', $data->items[$i]->author->url); + $this->assertNotEmpty($data->items[$i]->url); + $this->assertNotEmpty($data->items[$i]->published); + $this->assertNotEmpty($data->items[$i]->content->html); + $this->assertNotEmpty($data->items[$i]->content->text); + } + + $this->assertEquals('2017-11-08T23:53:00-08:00', $data->items[0]->published); + $this->assertEquals('http://tantek.com/2017/312/t3/tam-trail-run-first-trail-half', $data->items[0]->url); + + $this->assertEquals('went to MORE Pancakes! this morning @RunJanji pop-up on California st after #NPSF. Picked up a new running shirt.', $data->items[1]->content->text); + $this->assertEquals('went to MORE Pancakes! this morning @RunJanji pop-up on California st after #NPSF. Picked up a new running shirt.', $data->items[1]->content->html); + + $this->assertEquals('feed', $data->type); } - } - - public function testJSONFeedRelativeImages() { - $url = 'http://feed.example.com/jsonfeed'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('feed+json', $result->{'source-format'}); - $data = $result->data; - - // Relative image on an item that has a url - $this->assertEquals('http://www.manton.org/2017/11/image.jpg', $data->items[9]->photo[0]); - - // Relative image on an item that has no URL, fall back to feed URL - $this->assertEquals('http://feed.example.com/image.jpg', $data->items[10]->photo[0]); - - // Relative image inside the content html - $this->assertContains('http://www.manton.org/2017/11/img.jpg', $data->items[9]->content->html); - } - - public function testAtomFeed() { - $url = 'http://feed.example.com/atom'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('xml', $result->{'source-format'}); - $data = $result->data; - - $this->assertEquals(8, count($data->items)); - for($i=0; $i<8; $i++) { - $this->assertEquals('entry', $data->items[$i]->type); - $this->assertEquals('note', $data->items[$i]->{'post-type'}); - $this->assertEquals('Tantek', $data->items[$i]->author->name); - $this->assertEquals('http://tantek.com/', $data->items[$i]->author->url); - $this->assertNotEmpty($data->items[$i]->url); - $this->assertNotEmpty($data->items[$i]->published); - $this->assertNotEmpty($data->items[$i]->content->html); - $this->assertNotEmpty($data->items[$i]->content->text); + + public function testRSSFeed() + { + $url = 'http://feed.example.com/rss'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('xml', $result->{'source-format'}); + $data = $result->data; + + $this->assertEquals(10, count($data->items)); + for($i=0; $i<10; $i++) { + $this->assertEquals('entry', $data->items[$i]->type); + $this->assertEquals(($i == 4 ? 'article' : 'note'), $data->items[$i]->{'post-type'}); + $this->assertEquals('Ryan Barrett', $data->items[$i]->author->name); + $this->assertEquals('https://snarfed.org/', $data->items[$i]->author->url); + $this->assertNotEmpty($data->items[$i]->url); + $this->assertNotEmpty($data->items[$i]->published); + $this->assertNotEmpty($data->items[$i]->content->html); + if($i > 1) { + $this->assertNotEmpty($data->items[$i]->content->text); + } + } + + $this->assertEquals('2017-09-12T20:09:12+00:00', $data->items[9]->published); + $this->assertEquals('https://snarfed.org/2017-09-12_25492', $data->items[9]->url); + $this->assertEquals( + '

new business cards 😂

+

IMG_20170912_131414_767.jpg?w=696&ssl=1

', $data->items[9]->content->html + ); + $this->assertEquals('new business cards', $data->items[9]->content->text); + + $this->assertEquals('feed', $data->type); } - $this->assertEquals('2017-11-08T23:53:00-08:00', $data->items[0]->published); - $this->assertEquals('http://tantek.com/2017/312/t3/tam-trail-run-first-trail-half', $data->items[0]->url); - - $this->assertEquals('went to MORE Pancakes! this morning @RunJanji pop-up on California st after #NPSF. Picked up a new running shirt.', $data->items[1]->content->text); - $this->assertEquals('went to MORE Pancakes! this morning @RunJanji pop-up on California st after #NPSF. Picked up a new running shirt.', $data->items[1]->content->html); - - $this->assertEquals('feed', $data->type); - } - - public function testRSSFeed() { - $url = 'http://feed.example.com/rss'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('xml', $result->{'source-format'}); - $data = $result->data; - - $this->assertEquals(10, count($data->items)); - for($i=0; $i<10; $i++) { - $this->assertEquals('entry', $data->items[$i]->type); - $this->assertEquals(($i == 4 ? 'article' : 'note'), $data->items[$i]->{'post-type'}); - $this->assertEquals('Ryan Barrett', $data->items[$i]->author->name); - $this->assertEquals('https://snarfed.org/', $data->items[$i]->author->url); - $this->assertNotEmpty($data->items[$i]->url); - $this->assertNotEmpty($data->items[$i]->published); - $this->assertNotEmpty($data->items[$i]->content->html); - if($i > 1) - $this->assertNotEmpty($data->items[$i]->content->text); + public function testPodcastFeed() + { + $url = 'http://feed.example.com/podcast-rss'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('xml', $result->{'source-format'}); + $data = $result->data; + + $this->assertEquals(12, count($data->items)); + for($i=0; $i<12; $i++) { + $this->assertEquals('entry', $data->items[$i]->type); + $this->assertEquals('audio', $data->items[$i]->{'post-type'}); + $this->assertEquals('Aaron Parecki', $data->items[$i]->author->name); + $this->assertEquals('https://percolator.today/', $data->items[$i]->author->url); + $this->assertNotEmpty($data->items[$i]->url); + $this->assertNotEmpty($data->items[$i]->published); + $this->assertNotEmpty($data->items[$i]->name); + $this->assertNotEmpty($data->items[$i]->content->html); + $this->assertNotEmpty($data->items[$i]->content->text); + $this->assertNotEmpty($data->items[$i]->audio); + } + + $this->assertEquals('Episode 1: Welcome', $data->items[11]->name); + $this->assertEquals('https://percolator.today/episode/1', $data->items[11]->url); + $this->assertEquals('2017-09-20T07:00:00+00:00', $data->items[11]->published); + $this->assertEquals('https://percolator.today/redirect.php?url=https%3A%2F%2Fpercolator.today%2Fmedia%2FPercolator_Episode_1.mp3', $data->items[11]->audio[0]); + $this->assertStringContainsString('What is Percolator? Some thoughts about multi-photos in Instagram.', $data->items[11]->content->text); + $this->assertStringContainsString('What is Percolator? Some thoughts about multi-photos in Instagram.', $data->items[11]->content->html); + $this->assertStringContainsString('
  • multi-photo vs collection
  • ', $data->items[11]->content->html); + + $this->assertEquals('feed', $data->type); } - $this->assertEquals('2017-09-12T20:09:12+00:00', $data->items[9]->published); - $this->assertEquals('https://snarfed.org/2017-09-12_25492', $data->items[9]->url); - $this->assertEquals('

    new business cards 😂

    -

    IMG_20170912_131414_767.jpg?w=696&ssl=1

    ', $data->items[9]->content->html); - $this->assertEquals('new business cards', $data->items[9]->content->text); - - $this->assertEquals('feed', $data->type); - } - - public function testPodcastFeed() { - $url = 'http://feed.example.com/podcast-rss'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('xml', $result->{'source-format'}); - $data = $result->data; - - $this->assertEquals(12, count($data->items)); - for($i=0; $i<12; $i++) { - $this->assertEquals('entry', $data->items[$i]->type); - $this->assertEquals('audio', $data->items[$i]->{'post-type'}); - $this->assertEquals('Aaron Parecki', $data->items[$i]->author->name); - $this->assertEquals('https://percolator.today/', $data->items[$i]->author->url); - $this->assertNotEmpty($data->items[$i]->url); - $this->assertNotEmpty($data->items[$i]->published); - $this->assertNotEmpty($data->items[$i]->name); - $this->assertNotEmpty($data->items[$i]->content->html); - $this->assertNotEmpty($data->items[$i]->content->text); - $this->assertNotEmpty($data->items[$i]->audio); + public function testInstagramAtomFeed() + { + $url = 'http://feed.example.com/instagram-atom'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $result = json_decode($body); + $this->assertEquals('xml', $result->{'source-format'}); + $data = $result->data; + $this->assertEquals(12, count($data->items)); + + $this->assertEquals('Marshall Kirkpatrick', $data->items[11]->author->name); + $this->assertEquals('https://www.instagram.com/marshallk/', $data->items[11]->author->url); + $this->assertEquals('https://www.instagram.com/p/BcFjw9SHYql/', $data->items[11]->url); + $this->assertEquals('2017-11-29T17:04:00+00:00', $data->items[11]->published); + // Should remove the "name" since it's a prefix of the content + $this->assertObjectNotHasAttribute('name', $data->items[11]); + $this->assertEquals('Sometimes my job requires me to listen to 55 minutes of an hour long phone call while I go for a long walk on a sunny morning and wait for my turn to give an update. Pretty nice!', $data->items[11]->content->text); } - $this->assertEquals('Episode 1: Welcome', $data->items[11]->name); - $this->assertEquals('https://percolator.today/episode/1', $data->items[11]->url); - $this->assertEquals('2017-09-20T07:00:00+00:00', $data->items[11]->published); - $this->assertEquals('https://percolator.today/redirect.php?url=https%3A%2F%2Fpercolator.today%2Fmedia%2FPercolator_Episode_1.mp3', $data->items[11]->audio[0]); - $this->assertContains('What is Percolator? Some thoughts about multi-photos in Instagram.', $data->items[11]->content->text); - $this->assertContains('What is Percolator? Some thoughts about multi-photos in Instagram.', $data->items[11]->content->html); - $this->assertContains('
  • multi-photo vs collection
  • ', $data->items[11]->content->html); - - $this->assertEquals('feed', $data->type); - } - - public function testInstagramAtomFeed() { - $url = 'http://feed.example.com/instagram-atom'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $result = json_decode($body); - $this->assertEquals('xml', $result->{'source-format'}); - $data = $result->data; - $this->assertEquals(12, count($data->items)); - - $this->assertEquals('Marshall Kirkpatrick', $data->items[11]->author->name); - $this->assertEquals('https://www.instagram.com/marshallk/', $data->items[11]->author->url); - $this->assertEquals('https://www.instagram.com/p/BcFjw9SHYql/', $data->items[11]->url); - $this->assertEquals('2017-11-29T17:04:00+00:00', $data->items[11]->published); - // Should remove the "name" since it's a prefix of the content - $this->assertObjectNotHasAttribute('name', $data->items[11]); - $this->assertEquals('Sometimes my job requires me to listen to 55 minutes of an hour long phone call while I go for a long walk on a sunny morning and wait for my turn to give an update. Pretty nice!', $data->items[11]->content->text); - } - - public function testAscraeus() { - $url = 'http://source.example.com/ascraeus'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body)->data; - - $this->assertEquals('feed', $data->type); - $this->assertEquals(20, count($data->items)); - } - - public function testAdactioLinks() { - $url = 'http://feed.example.com/adactio-links'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body)->data; - - $this->assertEquals('feed', $data->type); - // 20 h-entrys followed by one h-card, which should have been removed and used as the author instead - $this->assertEquals(20, count($data->items)); - $this->assertEquals('http://feed.example.com/links/14501', $data->items[0]->url); - $this->assertEquals('http://feed.example.com/links/14445', $data->items[19]->url); - $item = $data->items[0]; - $this->assertEquals('Jeremy Keith', $item->author->name); - $this->assertEquals('https://adactio.com/', $item->author->url); - } - - public function testWaterpigsFeed() { - $url = 'http://feed.example.com/waterpigs'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body)->data; - - $this->assertEquals('feed', $data->type); - $this->assertEquals(21, count($data->items)); - $item = $data->items[16]; - $this->assertEquals('Barnaby Walters', $item->author->name); - $this->assertEquals('https://waterpigs.co.uk', $item->author->url); - } - - public function testRSSWithNoXMLTag() { - $url = 'http://feed.example.com/rss-no-xml-tag'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body)->data; - - $this->assertEquals('feed', $data->type); - } - - public function testAuthorFeedOnHomePage() { - $url = 'http://feed.example.com/h-feed-author-is-feed'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $parsed = json_decode($body, true); - $data = $parsed['data']; - - $this->assertEquals('feed', $data['type']); - $this->assertEquals('http://author.example.com/h-feed-author', $data['items'][0]['author']['url']); - $this->assertEquals('Author', $data['items'][0]['author']['name']); - $this->assertEquals('http://author.example.com/h-feed-author', $data['items'][1]['author']['url']); - $this->assertEquals('Author', $data['items'][1]['author']['name']); - } - - public function testAuthorFeedOnHomePageInvalid() { - $url = 'http://feed.example.com/h-feed-author-is-bad-feed'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $parsed = json_decode($body, true); - $data = $parsed['data']; - - $this->assertEquals('feed', $data['type']); - $this->assertEquals('http://author.example.com/h-feed-author-bad', $data['items'][0]['author']['url']); - $this->assertEquals('http://author.example.com/h-feed-author-bad', $data['items'][1]['author']['url']); - } + public function testAscraeus() + { + $url = 'http://source.example.com/ascraeus'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body)->data; + + $this->assertEquals('feed', $data->type); + $this->assertEquals(20, count($data->items)); + } + + public function testAdactioLinks() + { + $url = 'http://feed.example.com/adactio-links'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body)->data; + + $this->assertEquals('feed', $data->type); + // 20 h-entrys followed by one h-card, which should have been removed and used as the author instead + $this->assertEquals(20, count($data->items)); + $this->assertEquals('http://feed.example.com/links/14501', $data->items[0]->url); + $this->assertEquals('http://feed.example.com/links/14445', $data->items[19]->url); + $item = $data->items[0]; + $this->assertEquals('Jeremy Keith', $item->author->name); + $this->assertEquals('https://adactio.com/', $item->author->url); + } + + public function testWaterpigsFeed() + { + $url = 'http://feed.example.com/waterpigs'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body)->data; + + $this->assertEquals('feed', $data->type); + $this->assertEquals(21, count($data->items)); + $item = $data->items[16]; + $this->assertEquals('Barnaby Walters', $item->author->name); + $this->assertEquals('https://waterpigs.co.uk', $item->author->url); + } + + public function testRSSWithNoXMLTag() + { + $url = 'http://feed.example.com/rss-no-xml-tag'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body)->data; + + $this->assertEquals('feed', $data->type); + } + + public function testAuthorFeedOnHomePage() + { + $url = 'http://feed.example.com/h-feed-author-is-feed'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $parsed = json_decode($body, true); + $data = $parsed['data']; + + $this->assertEquals('feed', $data['type']); + $this->assertEquals('http://author.example.com/h-feed-author', $data['items'][0]['author']['url']); + $this->assertEquals('Author', $data['items'][0]['author']['name']); + $this->assertEquals('http://author.example.com/h-feed-author', $data['items'][1]['author']['url']); + $this->assertEquals('Author', $data['items'][1]['author']['name']); + } + + public function testAuthorFeedOnHomePageInvalid() + { + $url = 'http://feed.example.com/h-feed-author-is-bad-feed'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $parsed = json_decode($body, true); + $data = $parsed['data']; + + $this->assertEquals('feed', $data['type']); + $this->assertEquals('http://author.example.com/h-feed-author-bad', $data['items'][0]['author']['url']); + $this->assertEquals('http://author.example.com/h-feed-author-bad', $data['items'][1]['author']['url']); + } } diff --git a/tests/FetchTest.php b/tests/FetchTest.php index a274197..1e6b59d 100644 --- a/tests/FetchTest.php +++ b/tests/FetchTest.php @@ -2,192 +2,231 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class FetchTest extends PHPUnit_Framework_TestCase { - - private $http; - - public function setUp() { - $this->client = new Parse(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->parse($request, $response); - } - - public function testRedirectLimit() { - $url = 'http://redirect.example.com/3'; - $response = $this->parse([ - 'url' => $url, - 'max_redirects' => 1 - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('too_many_redirects', $data->error); - - $url = 'http://redirect.example.com/2'; - $response = $this->parse([ - 'url' => $url, - 'max_redirects' => 1 - ]); - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('too_many_redirects', $data->error); - } - - public function testRedirectUnderLimit() { - $url = 'http://redirect.example.com/2'; - $response = $this->parse([ - 'url' => $url, - 'max_redirects' => 2 - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - $this->assertEquals(200, $data->code); - $this->assertEquals('The Final Page', $data->data->name); - $this->assertEquals('http://redirect.example.com/0', $data->url); - } - - public function testReturnsHTTPStatusCode() { - $url = 'http://redirect.example.com/code-418'; - $response = $this->parse([ - 'url' => $url - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - $this->assertEquals($url, $data->url); - $this->assertEquals(418, $data->code); - } - - public function testReturnsForbidden() { - $url = 'http://redirect.example.com/code-403'; - $response = $this->parse([ - 'url' => $url - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('forbidden', $data->error); - $this->assertEquals($url, $data->url); - $this->assertEquals(403, $data->code); - } - - public function testReturnsUnauthorized() { - $url = 'http://redirect.example.com/code-401'; - $response = $this->parse([ - 'url' => $url - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('unauthorized', $data->error); - $this->assertEquals($url, $data->url); - $this->assertEquals(401, $data->code); - } - - public function testDeleted() { - $url = 'http://source.example.com/deleted-gone'; - $response = $this->parse([ - 'url' => $url - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - $this->assertEquals(410, $data->code); - $this->assertEquals('This post has been deleted.', $data->data->content->text); - } - - public function testDeletedEmptyBody() { - $url = 'http://source.example.com/deleted-empty'; - $response = $this->parse([ - 'url' => $url - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - $this->assertEquals(410, $data->code); - $this->assertEquals('unknown', $data->data->type); - } - - public function testDeletedTargetProvided() { - $url = 'http://source.example.com/deleted-gone'; - $response = $this->parse([ - 'url' => $url, - 'target' => 'http://example.com/' - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('no_link_found', $data->error); - $this->assertEquals(410, $data->code); - } - - public function testMetaEquivDeleted() { - $url = 'http://source.example.com/deleted'; - $response = $this->parse([ - 'url' => $url - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - $this->assertEquals(410, $data->code); - $this->assertEquals('This post has been deleted.', $data->data->content->text); - } - - public function testMetaEquivDeletedCaps() { - $url = 'http://source.example.com/deleted-2'; - $response = $this->parse([ - 'url' => $url - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - $this->assertEquals(410, $data->code); - $this->assertEquals('This post has been deleted.', $data->data->content->text); - } - - public function testMetaEquivDeletedTargetProvided() { - // for example when verifying a webmention but the source was replaced with an html deleted page - - $url = 'http://source.example.com/deleted'; - $response = $this->parse([ - 'url' => $url, - 'target' => 'http://example.com/' - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('no_link_found', $data->error); - $this->assertEquals(410, $data->code); - } +class FetchTest extends PHPUnit\Framework\TestCase +{ + + private $http; + + public function setUp(): void + { + $this->client = new Parse(); + $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); + $this->client->mc = null; + + } + + private function parse($params) + { + $request = new Request($params); + $response = new Response(); + return $this->client->parse($request, $response); + } + + public function testRedirectLimit() + { + $url = 'http://redirect.example.com/3'; + $response = $this->parse( + [ + 'url' => $url, + 'max_redirects' => 1 + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('too_many_redirects', $data->error); + + $url = 'http://redirect.example.com/2'; + $response = $this->parse( + [ + 'url' => $url, + 'max_redirects' => 1 + ] + ); + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('too_many_redirects', $data->error); + } + + public function testRedirectUnderLimit() + { + $url = 'http://redirect.example.com/2'; + $response = $this->parse( + [ + 'url' => $url, + 'max_redirects' => 2 + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + $this->assertEquals(200, $data->code); + $this->assertEquals('The Final Page', $data->data->name); + $this->assertEquals('http://redirect.example.com/0', $data->url); + } + + public function testReturnsHTTPStatusCode() + { + $url = 'http://redirect.example.com/code-418'; + $response = $this->parse( + [ + 'url' => $url + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + $this->assertEquals($url, $data->url); + $this->assertEquals(418, $data->code); + } + + public function testReturnsForbidden() + { + $url = 'http://redirect.example.com/code-403'; + $response = $this->parse( + [ + 'url' => $url + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('forbidden', $data->error); + $this->assertEquals($url, $data->url); + $this->assertEquals(403, $data->code); + } + + public function testReturnsUnauthorized() + { + $url = 'http://redirect.example.com/code-401'; + $response = $this->parse( + [ + 'url' => $url + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('unauthorized', $data->error); + $this->assertEquals($url, $data->url); + $this->assertEquals(401, $data->code); + } + + public function testDeleted() + { + $url = 'http://source.example.com/deleted-gone'; + $response = $this->parse( + [ + 'url' => $url + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + $this->assertEquals(410, $data->code); + $this->assertEquals('This post has been deleted.', $data->data->content->text); + } + + public function testDeletedEmptyBody() + { + $url = 'http://source.example.com/deleted-empty'; + $response = $this->parse( + [ + 'url' => $url + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + $this->assertEquals(410, $data->code); + $this->assertEquals('unknown', $data->data->type); + } + + public function testDeletedTargetProvided() + { + $url = 'http://source.example.com/deleted-gone'; + $response = $this->parse( + [ + 'url' => $url, + 'target' => 'http://example.com/' + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('no_link_found', $data->error); + $this->assertEquals(410, $data->code); + } + + public function testMetaEquivDeleted() + { + $url = 'http://source.example.com/deleted'; + $response = $this->parse( + [ + 'url' => $url + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + $this->assertEquals(410, $data->code); + $this->assertEquals('This post has been deleted.', $data->data->content->text); + } + + public function testMetaEquivDeletedCaps() + { + $url = 'http://source.example.com/deleted-2'; + $response = $this->parse( + [ + 'url' => $url + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + $this->assertEquals(410, $data->code); + $this->assertEquals('This post has been deleted.', $data->data->content->text); + } + + public function testMetaEquivDeletedTargetProvided() + { + // for example when verifying a webmention but the source was replaced with an html deleted page + + $url = 'http://source.example.com/deleted'; + $response = $this->parse( + [ + 'url' => $url, + 'target' => 'http://example.com/' + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('no_link_found', $data->error); + $this->assertEquals(410, $data->code); + } } diff --git a/tests/FetchTestDisabled.php b/tests/FetchTestDisabled.php index e3c2e4a..b939370 100644 --- a/tests/FetchTestDisabled.php +++ b/tests/FetchTestDisabled.php @@ -2,32 +2,37 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class FetchTest extends PHPUnit_Framework_TestCase { +class FetchTest extends PHPUnit\Framework\TestCase +{ - private $http; + private $http; - public function setUp() { - $this->http = new p3k\HTTP(); - } + public function setUp(): void + { + $this->http = new p3k\HTTP(); + } - public function testTimeout() { - $url = 'https://nghttp2.org/httpbin/delay/2'; - $this->http->timeout = 1; - $response = $this->http->get($url); - $this->assertEquals('timeout', $response['error']); - } + public function testTimeout() + { + $url = 'https://nghttp2.org/httpbin/delay/2'; + $this->http->timeout = 1; + $response = $this->http->get($url); + $this->assertEquals('timeout', $response['error']); + } - public function testRedirectLimit() { - $url = 'https://nghttp2.org/httpbin/redirect/3'; - $this->http->max_redirects = 1; - $response = $this->http->get($url); - $this->assertEquals('too_many_redirects', $response['error']); - } + public function testRedirectLimit() + { + $url = 'https://nghttp2.org/httpbin/redirect/3'; + $this->http->max_redirects = 1; + $response = $this->http->get($url); + $this->assertEquals('too_many_redirects', $response['error']); + } - public function testNoError() { - $url = 'https://nghttp2.org/httpbin/ip'; - $response = $this->http->get($url); - $this->assertEquals('', $response['error']); - } + public function testNoError() + { + $url = 'https://nghttp2.org/httpbin/ip'; + $response = $this->http->get($url); + $this->assertEquals('', $response['error']); + } } \ No newline at end of file diff --git a/tests/FindFeedsTest.php b/tests/FindFeedsTest.php index f4f2269..cf2467b 100644 --- a/tests/FindFeedsTest.php +++ b/tests/FindFeedsTest.php @@ -2,221 +2,238 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class FindFeedsTest extends PHPUnit_Framework_TestCase { - - private $http; - - public function setUp() { - $this->client = new Feeds(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->find($request, $response); - } - - // h-feed with no alternates - public function testMf2HFeed() { - $url = 'http://feed.example.com/h-feed-with-child-author'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/h-feed-with-child-author', $feeds[0]->url); - $this->assertEquals('microformats', $feeds[0]->type); - } - - // h-feed that links to Atom alternate - public function testMf2WithAtomAlternate() { - $url = 'http://feed.example.com/h-feed-with-atom-alternate'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(2, count($feeds)); - // Should rank h-feed above Atom - $this->assertEquals('http://feed.example.com/h-feed-with-atom-alternate', $feeds[0]->url); - $this->assertEquals('microformats', $feeds[0]->type); - $this->assertEquals('http://feed.example.com/atom', $feeds[1]->url); - $this->assertEquals('atom', $feeds[1]->type); - } - - // h-feed that links to RSS alternate - public function testMf2WithRSSAlternate() { - $url = 'http://feed.example.com/h-feed-with-rss-alternate'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(2, count($feeds)); - // Should rank JSONFeed above Atom - $this->assertEquals('http://feed.example.com/h-feed-with-rss-alternate', $feeds[0]->url); - $this->assertEquals('microformats', $feeds[0]->type); - $this->assertEquals('http://feed.example.com/podcast.xml', $feeds[1]->url); - $this->assertEquals('rss', $feeds[1]->type); - } - - // No mf2 but links to Atom alternate - public function testNoMf2() { - $url = 'http://feed.example.com/html-with-atom-alternate'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/atom', $feeds[0]->url); - $this->assertEquals('atom', $feeds[0]->type); - } - - public function testNoMf2WithJSONAndAtom() { - $url = 'http://feed.example.com/html-with-json-and-atom'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(2, count($feeds)); - // Should rank JSONFeed above Atom - $this->assertEquals('http://feed.example.com/jsonfeed', $feeds[0]->url); - $this->assertEquals('jsonfeed', $feeds[0]->type); - $this->assertEquals('http://feed.example.com/atom', $feeds[1]->url); - $this->assertEquals('atom', $feeds[1]->type); - } - - // input URL is an Atom feed - public function testInputIsAtom() { - $url = 'http://feed.example.com/atom'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/atom', $feeds[0]->url); - $this->assertEquals('atom', $feeds[0]->type); - } - - // input URL is an RSS feed with xml content type - public function testInputIsRSSWithXML() { - $url = 'http://feed.example.com/rss-xml-content-type'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/rss-xml-content-type', $feeds[0]->url); - $this->assertEquals('rss', $feeds[0]->type); - } - - // input URL redirects to an Atom feed - public function testInputIsRedirectToAtom() { - $url = 'http://feed.example.com/redirect-to-atom'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/atom', $feeds[0]->url); - $this->assertEquals('atom', $feeds[0]->type); - } - - // input URL is a temporary redirect to another page. - // report the original input URL - public function testInputIsTemporaryRedirect() { - $url = 'http://feed.example.com/temporary-redirect'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/temporary-redirect', $feeds[0]->url); - $this->assertEquals('microformats', $feeds[0]->type); - } - - public function testInputIsPermanentRedirect() { - $url = 'http://feed.example.com/permanent-redirect'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/permanent-redirect-target', $feeds[0]->url); - $this->assertEquals('microformats', $feeds[0]->type); - } - - // input URL is an RSS feed - public function testInputIsRSS() { - $url = 'http://feed.example.com/rss'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/rss', $feeds[0]->url); - $this->assertEquals('rss', $feeds[0]->type); - } - - // input URL is a JSON feed - public function testInputIsJSONFeed() { - $url = 'http://feed.example.com/jsonfeed'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/jsonfeed', $feeds[0]->url); - $this->assertEquals('jsonfeed', $feeds[0]->type); - } - - public function testInputIsMicroformats2JSON() { - $url = 'http://feed.example.com/microformats2-json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/microformats2-json', $feeds[0]->url); - $this->assertEquals('microformats', $feeds[0]->type); - } - - public function testInputIsMF2JSON() { - $url = 'http://feed.example.com/mf2-json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $feeds = json_decode($body)->feeds; - - $this->assertEquals(1, count($feeds)); - $this->assertEquals('http://feed.example.com/mf2-json', $feeds[0]->url); - $this->assertEquals('microformats', $feeds[0]->type); - } +class FindFeedsTest extends PHPUnit\Framework\TestCase +{ + + private $http; + + public function setUp(): void + { + $this->client = new Feeds(); + $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); + $this->client->mc = null; + } + + private function parse($params) + { + $request = new Request($params); + $response = new Response(); + return $this->client->find($request, $response); + } + + // h-feed with no alternates + public function testMf2HFeed() + { + $url = 'http://feed.example.com/h-feed-with-child-author'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/h-feed-with-child-author', $feeds[0]->url); + $this->assertEquals('microformats', $feeds[0]->type); + } + + // h-feed that links to Atom alternate + public function testMf2WithAtomAlternate() + { + $url = 'http://feed.example.com/h-feed-with-atom-alternate'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(2, count($feeds)); + // Should rank h-feed above Atom + $this->assertEquals('http://feed.example.com/h-feed-with-atom-alternate', $feeds[0]->url); + $this->assertEquals('microformats', $feeds[0]->type); + $this->assertEquals('http://feed.example.com/atom', $feeds[1]->url); + $this->assertEquals('atom', $feeds[1]->type); + } + + // h-feed that links to RSS alternate + public function testMf2WithRSSAlternate() + { + $url = 'http://feed.example.com/h-feed-with-rss-alternate'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(2, count($feeds)); + // Should rank JSONFeed above Atom + $this->assertEquals('http://feed.example.com/h-feed-with-rss-alternate', $feeds[0]->url); + $this->assertEquals('microformats', $feeds[0]->type); + $this->assertEquals('http://feed.example.com/podcast.xml', $feeds[1]->url); + $this->assertEquals('rss', $feeds[1]->type); + } + + // No mf2 but links to Atom alternate + public function testNoMf2() + { + $url = 'http://feed.example.com/html-with-atom-alternate'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/atom', $feeds[0]->url); + $this->assertEquals('atom', $feeds[0]->type); + } + + public function testNoMf2WithJSONAndAtom() + { + $url = 'http://feed.example.com/html-with-json-and-atom'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(2, count($feeds)); + // Should rank JSONFeed above Atom + $this->assertEquals('http://feed.example.com/jsonfeed', $feeds[0]->url); + $this->assertEquals('jsonfeed', $feeds[0]->type); + $this->assertEquals('http://feed.example.com/atom', $feeds[1]->url); + $this->assertEquals('atom', $feeds[1]->type); + } + + // input URL is an Atom feed + public function testInputIsAtom() + { + $url = 'http://feed.example.com/atom'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/atom', $feeds[0]->url); + $this->assertEquals('atom', $feeds[0]->type); + } + + // input URL is an RSS feed with xml content type + public function testInputIsRSSWithXML() + { + $url = 'http://feed.example.com/rss-xml-content-type'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/rss-xml-content-type', $feeds[0]->url); + $this->assertEquals('rss', $feeds[0]->type); + } + + // input URL redirects to an Atom feed + public function testInputIsRedirectToAtom() + { + $url = 'http://feed.example.com/redirect-to-atom'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/atom', $feeds[0]->url); + $this->assertEquals('atom', $feeds[0]->type); + } + + // input URL is a temporary redirect to another page. + // report the original input URL + public function testInputIsTemporaryRedirect() + { + $url = 'http://feed.example.com/temporary-redirect'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/temporary-redirect', $feeds[0]->url); + $this->assertEquals('microformats', $feeds[0]->type); + } + + public function testInputIsPermanentRedirect() + { + $url = 'http://feed.example.com/permanent-redirect'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/permanent-redirect-target', $feeds[0]->url); + $this->assertEquals('microformats', $feeds[0]->type); + } + + // input URL is an RSS feed + public function testInputIsRSS() + { + $url = 'http://feed.example.com/rss'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/rss', $feeds[0]->url); + $this->assertEquals('rss', $feeds[0]->type); + } + + // input URL is a JSON feed + public function testInputIsJSONFeed() + { + $url = 'http://feed.example.com/jsonfeed'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/jsonfeed', $feeds[0]->url); + $this->assertEquals('jsonfeed', $feeds[0]->type); + } + + public function testInputIsMicroformats2JSON() + { + $url = 'http://feed.example.com/microformats2-json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/microformats2-json', $feeds[0]->url); + $this->assertEquals('microformats', $feeds[0]->type); + } + + public function testInputIsMF2JSON() + { + $url = 'http://feed.example.com/mf2-json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $feeds = json_decode($body)->feeds; + + $this->assertEquals(1, count($feeds)); + $this->assertEquals('http://feed.example.com/mf2-json', $feeds[0]->url); + $this->assertEquals('microformats', $feeds[0]->type); + } } diff --git a/tests/GitHubTest.php b/tests/GitHubTest.php index d17a00e..611e4c3 100644 --- a/tests/GitHubTest.php +++ b/tests/GitHubTest.php @@ -2,130 +2,138 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class GitHubTest extends PHPUnit_Framework_TestCase { - - private $http; - - public function setUp() { - $this->client = new Parse(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->parse($request, $response); - } - - public function testGitHubPull() { - // Original URL: https://github.com/idno/Known/pull/1690 - $url = 'https://github.com/idno/Known/pull/1690'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('github', $data['source-format']); - - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('reply', $data['data']['post-type']); - $this->assertEquals('https://github.com/idno/Known', $data['data']['in-reply-to'][0]); - $this->assertEquals('2017-04-10T17:44:57Z', $data['data']['published']); - $this->assertEquals('aaronpk', $data['data']['author']['name']); - $this->assertEquals('https://github.com/aaronpk', $data['data']['author']['url']); - $this->assertEquals('https://avatars2.githubusercontent.com/u/113001?v=3', $data['data']['author']['photo']); - $this->assertEquals('#1690 fixes bookmark Microformats markup', $data['data']['name']); - $this->assertContains('

    Here\'s what I fixed or added:

    ', $data['data']['content']['html']); - $this->assertContains('## Here\'s what I fixed or added:', $data['data']['content']['text']); - } - - public function testGitHubIssue() { - $url = 'https://github.com/aaronpk/XRay/issues/25'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('github', $data['source-format']); - - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('reply', $data['data']['post-type']); - $this->assertEquals('https://github.com/aaronpk/XRay/issues', $data['data']['in-reply-to'][0]); - $this->assertEquals('2017-01-26T14:13:42Z', $data['data']['published']); - $this->assertEquals('sebsel', $data['data']['author']['name']); - $this->assertEquals('https://github.com/sebsel', $data['data']['author']['url']); - $this->assertEquals('https://avatars3.githubusercontent.com/u/16517999?v=3', $data['data']['author']['photo']); - $this->assertEquals('#25 Post type discovery', $data['data']['name']); - $this->assertContains('
    ', $data['data']['content']['html']); - $this->assertContains('', $data['data']['content']['html']); - $this->assertContains('> sebsel', $data['data']['content']['text']); - } - - public function testGitHubIssueWithCategory() { - $url = 'https://github.com/aaronpk/XRay/issues/20'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('github', $data['source-format']); - - $this->assertEquals('entry', $data['data']['type']); - $this->assertContains('silo', $data['data']['category']); - } - - public function testGitHubRepo() { - $url = 'https://github.com/aaronpk/XRay'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('github', $data['source-format']); - - $this->assertEquals('repo', $data['data']['type']); - $this->assertArrayNotHasKey('post-type', $data['data']); - $this->assertEquals('2016-02-19T16:53:20Z', $data['data']['published']); - $this->assertEquals('aaronpk', $data['data']['author']['name']); - $this->assertEquals('https://github.com/aaronpk', $data['data']['author']['url']); - $this->assertEquals('https://avatars2.githubusercontent.com/u/113001?v=3', $data['data']['author']['photo']); - $this->assertEquals('XRay', $data['data']['name']); - $this->assertEquals('X-Ray returns structured data from any URL', $data['data']['summary']); - } - - public function testGitHubIssueComment() { - $url = 'https://github.com/aaronpk/XRay/issues/25#issuecomment-275433926'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('github', $data['source-format']); - - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('reply', $data['data']['post-type']); - $this->assertEquals('https://github.com/aaronpk/XRay/issues/25', $data['data']['in-reply-to'][0]); - $this->assertEquals('2017-01-26T16:24:37Z', $data['data']['published']); - $this->assertEquals('sebsel', $data['data']['author']['name']); - $this->assertEquals('https://avatars3.githubusercontent.com/u/16517999?v=3', $data['data']['author']['photo']); - $this->assertEquals('https://github.com/sebsel', $data['data']['author']['url']); - $this->assertContains('

    Well it\'s just that php-comments does more than XRay does currently. But that\'s no good reason.

    ', $data['data']['content']['html']); - $this->assertContains('', $data['data']['content']['html']); - $this->assertContains('```php', $data['data']['content']['text']); - $this->assertNotContains('name', $data['data']); - $this->assertContains('https://github.com/aaronpk/XRay/issues/25', $data['data']['in-reply-to']); - } +class GitHubTest extends PHPUnit\Framework\TestCase +{ + + private $http; + + public function setUp(): void + { + $this->client = new Parse(); + $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); + $this->client->mc = null; + } + + private function parse($params) + { + $request = new Request($params); + $response = new Response(); + return $this->client->parse($request, $response); + } + + public function testGitHubPull() + { + // Original URL: https://github.com/idno/Known/pull/1690 + $url = 'https://github.com/idno/Known/pull/1690'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('github', $data['source-format']); + + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('reply', $data['data']['post-type']); + $this->assertEquals('https://github.com/idno/Known', $data['data']['in-reply-to'][0]); + $this->assertEquals('2017-04-10T17:44:57Z', $data['data']['published']); + $this->assertEquals('aaronpk', $data['data']['author']['name']); + $this->assertEquals('https://github.com/aaronpk', $data['data']['author']['url']); + $this->assertEquals('https://avatars2.githubusercontent.com/u/113001?v=3', $data['data']['author']['photo']); + $this->assertEquals('#1690 fixes bookmark Microformats markup', $data['data']['name']); + $this->assertStringContainsString('

    Here\'s what I fixed or added:

    ', $data['data']['content']['html']); + $this->assertStringContainsString('## Here\'s what I fixed or added:', $data['data']['content']['text']); + } + + public function testGitHubIssue() + { + $url = 'https://github.com/aaronpk/XRay/issues/25'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('github', $data['source-format']); + + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('reply', $data['data']['post-type']); + $this->assertEquals('https://github.com/aaronpk/XRay/issues', $data['data']['in-reply-to'][0]); + $this->assertEquals('2017-01-26T14:13:42Z', $data['data']['published']); + $this->assertEquals('sebsel', $data['data']['author']['name']); + $this->assertEquals('https://github.com/sebsel', $data['data']['author']['url']); + $this->assertEquals('https://avatars3.githubusercontent.com/u/16517999?v=3', $data['data']['author']['photo']); + $this->assertEquals('#25 Post type discovery', $data['data']['name']); + $this->assertStringContainsString('
    ', $data['data']['content']['html']); + $this->assertStringContainsString('', $data['data']['content']['html']); + $this->assertStringContainsString('> sebsel', $data['data']['content']['text']); + } + + public function testGitHubIssueWithCategory() + { + $url = 'https://github.com/aaronpk/XRay/issues/20'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('github', $data['source-format']); + + $this->assertEquals('entry', $data['data']['type']); + $this->assertContains('silo', $data['data']['category']); + } + + public function testGitHubRepo() + { + $url = 'https://github.com/aaronpk/XRay'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('github', $data['source-format']); + + $this->assertEquals('repo', $data['data']['type']); + $this->assertArrayNotHasKey('post-type', $data['data']); + $this->assertEquals('2016-02-19T16:53:20Z', $data['data']['published']); + $this->assertEquals('aaronpk', $data['data']['author']['name']); + $this->assertEquals('https://github.com/aaronpk', $data['data']['author']['url']); + $this->assertEquals('https://avatars2.githubusercontent.com/u/113001?v=3', $data['data']['author']['photo']); + $this->assertEquals('XRay', $data['data']['name']); + $this->assertEquals('X-Ray returns structured data from any URL', $data['data']['summary']); + } + + public function testGitHubIssueComment() + { + $url = 'https://github.com/aaronpk/XRay/issues/25#issuecomment-275433926'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('github', $data['source-format']); + + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('reply', $data['data']['post-type']); + $this->assertEquals('https://github.com/aaronpk/XRay/issues/25', $data['data']['in-reply-to'][0]); + $this->assertEquals('2017-01-26T16:24:37Z', $data['data']['published']); + $this->assertEquals('sebsel', $data['data']['author']['name']); + $this->assertEquals('https://avatars3.githubusercontent.com/u/16517999?v=3', $data['data']['author']['photo']); + $this->assertEquals('https://github.com/sebsel', $data['data']['author']['url']); + $this->assertStringContainsString('

    Well it\'s just that php-comments does more than XRay does currently. But that\'s no good reason.

    ', $data['data']['content']['html']); + $this->assertStringContainsString('', $data['data']['content']['html']); + $this->assertStringContainsString('```php', $data['data']['content']['text']); + $this->assertNotContains('name', $data['data']); + $this->assertContains('https://github.com/aaronpk/XRay/issues/25', $data['data']['in-reply-to']); + } } diff --git a/tests/HackernewsTest.php b/tests/HackernewsTest.php index cd171af..10b9e2f 100644 --- a/tests/HackernewsTest.php +++ b/tests/HackernewsTest.php @@ -2,76 +2,87 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class HackernewsTest extends PHPUnit_Framework_TestCase { +class HackernewsTest extends PHPUnit\Framework\TestCase +{ - private $http; + private $http; - public function setUp() { - $this->client = new Parse(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } + public function setUp(): void + { + $this->client = new Parse(); + $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); + $this->client->mc = null; + } - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->parse($request, $response); - } + private function parse($params) + { + $request = new Request($params); + $response = new Response(); + return $this->client->parse($request, $response); + } - public function testSubmission() { - $url = 'https://news.ycombinator.com/item?id=14516538'; - $response = $this->parse(['url' => $url]); + public function testSubmission() + { + $url = 'https://news.ycombinator.com/item?id=14516538'; + $response = $this->parse(['url' => $url]); - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); - $this->assertEquals(200, $data['code']); - $this->assertEquals('hackernews', $data['source-format']); + $this->assertEquals(200, $data['code']); + $this->assertEquals('hackernews', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('article', $data['data']['post-type']); - $this->assertEquals('2017-06-08T19:32:12+00:00', $data['data']['published']); - $this->assertEquals('vkb', $data['data']['author']['name']); - $this->assertEquals('https://news.ycombinator.com/user?id=vkb', $data['data']['author']['url']); - $this->assertEquals('What are we doing about Facebook, Google, and the closed internet?', $data['data']['name']); - $this->assertEquals('There have been many, many posts about how toxic advertising and Facebook are (I\'ve written many myself[1][2][3]) for our internet ecosystem today.

    What projects or companies are you working on to combat filter bubbles, walled gardens, emotional manipulation, and the like, and how can the HN community help you in your goals?

    [1]http://veekaybee.github.io/facebook-is-collecting-this/ + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('article', $data['data']['post-type']); + $this->assertEquals('2017-06-08T19:32:12+00:00', $data['data']['published']); + $this->assertEquals('vkb', $data['data']['author']['name']); + $this->assertEquals('https://news.ycombinator.com/user?id=vkb', $data['data']['author']['url']); + $this->assertEquals('What are we doing about Facebook, Google, and the closed internet?', $data['data']['name']); + $this->assertEquals( + 'There have been many, many posts about how toxic advertising and Facebook are (I\'ve written many myself[1][2][3]) for our internet ecosystem today.

    What projects or companies are you working on to combat filter bubbles, walled gardens, emotional manipulation, and the like, and how can the HN community help you in your goals?

    [1]http://veekaybee.github.io/facebook-is-collecting-this/ [2]http://veekaybee.github.io/content-is-dead/ -[3] http://veekaybee.github.io/who-is-doing-this-to-my-internet/

    ', $data['data']['content']['html']); - $this->assertEquals('There have been many, many posts about how toxic advertising and Facebook are (I\'ve written many myself[1][2][3]) for our internet ecosystem today. +[3] http://veekaybee.github.io/who-is-doing-this-to-my-internet/

    ', $data['data']['content']['html'] + ); + $this->assertEquals( + 'There have been many, many posts about how toxic advertising and Facebook are (I\'ve written many myself[1][2][3]) for our internet ecosystem today. What projects or companies are you working on to combat filter bubbles, walled gardens, emotional manipulation, and the like, and how can the HN community help you in your goals? [1]http://veekaybee.github.io/facebook-is-collecting-this/ [2]http://veekaybee.github.io/content-is-dead/ -[3] http://veekaybee.github.io/who-is-doing-this-to-my-internet/', $data['data']['content']['text']); - } +[3] http://veekaybee.github.io/who-is-doing-this-to-my-internet/', $data['data']['content']['text'] + ); + } - public function testComment() { - $url = 'https://news.ycombinator.com/item?id=14516923'; - $response = $this->parse(['url' => $url]); + public function testComment() + { + $url = 'https://news.ycombinator.com/item?id=14516923'; + $response = $this->parse(['url' => $url]); - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); - $this->assertEquals(200, $data['code']); - $this->assertEquals('hackernews', $data['source-format']); + $this->assertEquals(200, $data['code']); + $this->assertEquals('hackernews', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('reply', $data['data']['post-type']); - $this->assertEquals('2017-06-08T20:23:20+00:00', $data['data']['published']); - $this->assertEquals('aaronpk', $data['data']['author']['name']); - $this->assertEquals('https://news.ycombinator.com/user?id=aaronpk', $data['data']['author']['url']); - $this->assertEquals('https://news.ycombinator.com/item?id=14516538', $data['data']['in-reply-to'][0]); - $this->assertArrayNotHasKey('name', $data['data']); - $this->assertEquals('I am a member of the W3C Social Web Working Group (
    https://www.w3.org/wiki/Socialwg), and have been organizing IndieWebCamp (https://indieweb.org/) conferences in this space for the last 7 years. We\'ve been making a lot of progress:

    * https://www.w3.org/TR/webmention/ - cross-site commenting

    * https://www.w3.org/TR/micropub/ - API for apps to create posts on various servers

    * https://www.w3.org/TR/websub/ - realtime subscriptions to feeds

    * More: https://indieweb.org/specs

    We focus on making sure there are a plurality of implementations and approaches rather than trying to build a single software solution to solve everything.

    Try commenting on my copy of this post on my website by sending me a webmention! https://aaronparecki.com/2017/06/08/9/indieweb

    ', $data['data']['content']['html']); - $this->assertEquals('I am a member of the W3C Social Web Working Group (https://www.w3.org/wiki/Socialwg), and have been organizing IndieWebCamp (https://indieweb.org/) conferences in this space for the last 7 years. We\'ve been making a lot of progress: + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('reply', $data['data']['post-type']); + $this->assertEquals('2017-06-08T20:23:20+00:00', $data['data']['published']); + $this->assertEquals('aaronpk', $data['data']['author']['name']); + $this->assertEquals('https://news.ycombinator.com/user?id=aaronpk', $data['data']['author']['url']); + $this->assertEquals('https://news.ycombinator.com/item?id=14516538', $data['data']['in-reply-to'][0]); + $this->assertArrayNotHasKey('name', $data['data']); + $this->assertEquals('I am a member of the W3C Social Web Working Group (https://www.w3.org/wiki/Socialwg), and have been organizing IndieWebCamp (https://indieweb.org/) conferences in this space for the last 7 years. We\'ve been making a lot of progress:

    * https://www.w3.org/TR/webmention/ - cross-site commenting

    * https://www.w3.org/TR/micropub/ - API for apps to create posts on various servers

    * https://www.w3.org/TR/websub/ - realtime subscriptions to feeds

    * More: https://indieweb.org/specs

    We focus on making sure there are a plurality of implementations and approaches rather than trying to build a single software solution to solve everything.

    Try commenting on my copy of this post on my website by sending me a webmention! https://aaronparecki.com/2017/06/08/9/indieweb

    ', $data['data']['content']['html']); + $this->assertEquals( + 'I am a member of the W3C Social Web Working Group (https://www.w3.org/wiki/Socialwg), and have been organizing IndieWebCamp (https://indieweb.org/) conferences in this space for the last 7 years. We\'ve been making a lot of progress: * https://www.w3.org/TR/webmention/ - cross-site commenting * https://www.w3.org/TR/micropub/ - API for apps to create posts on various servers * https://www.w3.org/TR/websub/ - realtime subscriptions to feeds * More: https://indieweb.org/specs We focus on making sure there are a plurality of implementations and approaches rather than trying to build a single software solution to solve everything. -Try commenting on my copy of this post on my website by sending me a webmention! https://aaronparecki.com/2017/06/08/9/indieweb', $data['data']['content']['text']); - } +Try commenting on my copy of this post on my website by sending me a webmention! https://aaronparecki.com/2017/06/08/9/indieweb', $data['data']['content']['text'] + ); + } } diff --git a/tests/HelpersTest.php b/tests/HelpersTest.php index 0073aae..f8d344d 100644 --- a/tests/HelpersTest.php +++ b/tests/HelpersTest.php @@ -1,33 +1,39 @@ assertEquals('http://example.com/', $result); - } + public function testLowercaseHostname() + { + $url = 'http://Example.com/'; + $result = p3k\XRay\normalize_url($url); + $this->assertEquals('http://example.com/', $result); + } - public function testAddsSlashToBareDomain() { - $url = 'http://example.com'; - $result = p3k\XRay\normalize_url($url); - $this->assertEquals('http://example.com/', $result); - } + public function testAddsSlashToBareDomain() + { + $url = 'http://example.com'; + $result = p3k\XRay\normalize_url($url); + $this->assertEquals('http://example.com/', $result); + } - public function testDoesNotModify() { - $url = 'https://example.com/'; - $result = p3k\XRay\normalize_url($url); - $this->assertEquals('https://example.com/', $result); - } + public function testDoesNotModify() + { + $url = 'https://example.com/'; + $result = p3k\XRay\normalize_url($url); + $this->assertEquals('https://example.com/', $result); + } - public function testURLEquality() { - $url1 = 'https://example.com/'; - $url2 = 'https://example.com'; - $result = p3k\XRay\urls_are_equal($url1, $url2); - $this->assertEquals(true, $result); - } + public function testURLEquality() + { + $url1 = 'https://example.com/'; + $url2 = 'https://example.com'; + $result = p3k\XRay\urls_are_equal($url1, $url2); + $this->assertEquals(true, $result); + } - public function testFindMicroformatsByType() { - $html = <<
    Author @@ -46,12 +52,12 @@ class HelpersTest extends PHPUnit_Framework_TestCase {
    EOF; - $mf2 = \Mf2\parse($html); - $hcards = \p3k\XRay\Formats\Mf2::findAllMicroformatsByType($mf2, 'h-card'); - $this->assertEquals('/1', $hcards[0]['properties']['url'][0]); - $this->assertEquals('/2', $hcards[1]['properties']['url'][0]); - $this->assertEquals('/3', $hcards[2]['properties']['url'][0]); - $this->assertEquals('/4', $hcards[3]['properties']['url'][0]); - } + $mf2 = \Mf2\parse($html); + $hcards = \p3k\XRay\Formats\Mf2::findAllMicroformatsByType($mf2, 'h-card'); + $this->assertEquals('/1', $hcards[0]['properties']['url'][0]); + $this->assertEquals('/2', $hcards[1]['properties']['url'][0]); + $this->assertEquals('/3', $hcards[2]['properties']['url'][0]); + $this->assertEquals('/4', $hcards[3]['properties']['url'][0]); + } } diff --git a/tests/InstagramTest.php b/tests/InstagramTest.php index a2e102e..e45701c 100644 --- a/tests/InstagramTest.php +++ b/tests/InstagramTest.php @@ -2,297 +2,323 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class InstagramTest extends PHPUnit_Framework_TestCase { - - private $http; - - public function setUp() { - $this->client = new Parse(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->parse($request, $response); - } - - public function testInstagramPhoto() { - // Original URL: https://www.instagram.com/p/BO5rYVElvJq/ - $url = 'https://www.instagram.com/p/BO5rYVElvJq/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('photo', $data['data']['post-type']); - $this->assertEquals('2017-01-05T23:31:32+00:00', $data['data']['published']); - $this->assertContains('planning', $data['data']['category']); - $this->assertContains('2017', $data['data']['category']); - $this->assertEquals('Kind of crazy to see the whole year laid out like this. #planning #2017', $data['data']['content']['text']); - $this->assertEquals(1, count($data['data']['photo'])); - $this->assertEquals(['https://instagram.fsjc1-3.fna.fbcdn.net/vp/af9471f885e6197478d71807a7cbf297/5CBA6E5F/t51.2885-15/e35/15803256_1832278043695907_4846092951052353536_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net'], $data['data']['photo']); - $this->assertEquals('https://www.instagram.com/aaronpk/', $data['data']['author']['url']); - $this->assertEquals('Aaron Parecki', $data['data']['author']['name']); - $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/a2909937316893f18760f1077ca88fa1/5CBB520A/t51.2885-19/s150x150/14240576_268350536897085_1129715662_a.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['author']['photo']); - $this->assertArrayNotHasKey('meta', $data['data']); // make sure this does not include alt text (autogenerated placeholder from instagram) - } - - public function testBGDpqNoiMJ0() { - // https://www.instagram.com/p/BGDpqNoiMJ0/ - $url = 'http://www.instagram.com/BGDpqNoiMJ0'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('photo', $data['data']['post-type']); - $this->assertSame([ - 'type' => 'card', - 'name' => 'pk_spam', - 'nickname' => 'pk_spam', - 'url' => 'https://www.instagram.com/pk_spam/', - 'photo' => 'https://scontent-frx5-1.cdninstagram.com/vp/f17e1275a70fc32e93cbf434ddc32bcd/5B6CCC7A/t51.2885-19/11906329_960233084022564_1448528159_a.jpg', - ], $data['data']['author']); - - $this->assertSame([ - 'muffins', - 'https://www.instagram.com/indiewebcat/' - ], $data['data']['category']); - - $this->assertEquals('Meow #muffins', $data['data']['content']['text']); - $this->assertSame(['https://instagram.fsea1-1.fna.fbcdn.net/vp/9433ea494a8b055bebabf70fd81cfa32/5B51F092/t51.2885-15/e35/13266755_877794672348882_1908663476_n.jpg'], $data['data']['photo']); - $this->assertEquals('2016-05-30T20:46:22-07:00', $data['data']['published']); - - $this->assertEquals('https://www.instagram.com/explore/locations/359000003/', $data['data']['location'][0]); - - $this->assertSame([ - 'type' => 'card', - 'name' => 'Burnside 26', - 'url' => 'https://www.instagram.com/explore/locations/359000003/', - 'latitude' => 45.52322, - 'longitude' => -122.63885 - ], $data['data']['refs']['https://www.instagram.com/explore/locations/359000003/']); - } - - public function testInstagramVideo() { - // Original URL: https://www.instagram.com/p/BO_RN8AFZSx/ - $url = 'https://www.instagram.com/p/BO_RN8AFZSx/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('video', $data['data']['post-type']); - $this->assertContains('100daysofmusic', $data['data']['category']); - $this->assertEquals('Day 18. Maple and Spruce #100daysofmusic #100daysproject #the100dayproject https://aaronparecki.com/2017/01/07/14/day18', $data['data']['content']['text']); - $this->assertEquals(1, count($data['data']['photo'])); - $this->assertEquals(['https://instagram.fsjc1-3.fna.fbcdn.net/vp/a77f8672f977413d2eb5239cd6d5c4cf/5C3A4ADF/t51.2885-15/e15/15624670_548881701986735_8264383763249627136_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net'], $data['data']['photo']); - $this->assertEquals(1, count($data['data']['video'])); - $this->assertEquals(['https://instagram.fsjc1-3.fna.fbcdn.net/vp/90ed8fe576cba16e258c0f4cfc05299a/5C3A129E/t50.2886-16/15921147_1074837002642259_2269307616507199488_n.mp4?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net'], $data['data']['video']); - $this->assertEquals('https://www.instagram.com/aaronpk/', $data['data']['author']['url']); - $this->assertEquals('Aaron Parecki', $data['data']['author']['name']); - $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/a2909937316893f18760f1077ca88fa1/5CBB520A/t51.2885-19/s150x150/14240576_268350536897085_1129715662_a.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['author']['photo']); - } - - public function testInstagramPhotoWithPersonTag() { - // Original URL: https://www.instagram.com/p/BNfqVfVlmkj/ - $url = 'https://www.instagram.com/p/BNfqVfVlmkj/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals(2, count($data['data']['category'])); - $this->assertEquals(['type'=>'card','name'=>'KmikeyM™️','nickname'=>'kmikeym','url'=>'https://www.instagram.com/kmikeym/','photo'=>'https://instagram.fsjc1-3.fna.fbcdn.net/vp/ea5b988b616dbcc778b3013bf2426d70/5CCAC7FC/t51.2885-19/s320x320/20634957_814691788710973_2275383796935163904_a.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net','note'=>"The world’s first publicly traded person.\n•\nAcct in collaboration with @norbertoinc\n•\nBecome a shareholder today!\n•"], $data['data']['refs']['https://www.instagram.com/kmikeym/']); - $this->assertContains('https://www.instagram.com/kmikeym/', $data['data']['category']); - $this->assertArrayHasKey('https://www.instagram.com/kmikeym/', $data['data']['refs']); - } - - public function testInstagramPhotoWithVenue() { - // Original URL: https://www.instagram.com/p/BN3Z5salSys/ - $url = 'https://www.instagram.com/p/BN3Z5salSys/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals(1, count($data['data']['location'])); - $this->assertContains('https://www.instagram.com/explore/locations/109284789535230/', $data['data']['location']); - $this->assertArrayHasKey('https://www.instagram.com/explore/locations/109284789535230/', $data['data']['refs']); - $venue = $data['data']['refs']['https://www.instagram.com/explore/locations/109284789535230/']; - $this->assertEquals('XOXO Outpost', $venue['name']); - $this->assertEquals('45.5261002', $venue['latitude']); - $this->assertEquals('-122.6558081', $venue['longitude']); - // Setting a venue should set the timezone - $this->assertEquals('2016-12-10T21:48:56-08:00', $data['data']['published']); - } - - public function testTwoPhotos() { - // Original URL: https://www.instagram.com/p/BZWmUB_DVtp/ - $url = 'https://www.instagram.com/p/BZWmUB_DVtp/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals(2, count($data['data']['photo'])); - $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/6b09c3d5490ee3efb55849858a9ec014/5CBFBC38/t51.2885-15/e35/21827424_134752690591737_8093088291252862976_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][0]); - $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/8b1b2e6efa86a4856ec37a60f0fa77f5/5CC2D34D/t51.2885-15/e35/21909774_347707439021016_5237540582556958720_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][1]); - $this->assertArrayNotHasKey('video', $data['data']); - $this->assertEquals(2, count($data['data']['category'])); - $this->assertArrayNotHasKey('meta', $data['data']); - } - - public function testMixPhotosAndVideos() { - // Original URL: https://www.instagram.com/p/BZWmpecjBwN/ - $url = 'https://www.instagram.com/p/BZWmpecjBwN/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals('photo', $data['data']['post-type']); // we discard videos in this case right now - $this->assertEquals(3, count($data['data']['photo'])); - $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/ee1a28763918069f3e54dad35be24ad8/5CCFBAB8/t51.2885-15/e35/21878922_686481254874005_8468823712617988096_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][0]); - $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/ddc0ebe969bb1f9e6bf8adada0892c90/5C39EBC9/t51.2885-15/e15/21910026_1507234999368159_6974261907783942144_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][1]); - $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/bfe032af795427443ea448840df1c3a4/5CCC8C88/t51.2885-15/e35/21878800_273567963151023_7672178549897297920_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][2]); - $this->assertArrayNotHasKey('video', $data['data']); - $this->assertEquals(2, count($data['data']['category'])); - } - - public function testInstagramProfile() { - $url = 'https://www.instagram.com/aaronpk/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertSame([ - 'type' => 'card', - 'name' => 'Aaron Parecki', - 'nickname' => 'aaronpk', - 'url' => 'https://www.instagram.com/aaronpk/', - 'photo' => 'https://instagram.fsjc1-3.fna.fbcdn.net/vp/45aee453740a714bf408f8947f89da8e/5CCB4B8E/t51.2885-19/s320x320/14240576_268350536897085_1129715662_a.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', - 'note' => '🔒 oauth.net 🎥 backpedal.tv 🎙 streampdx.com 📡 w7apk.com' - ], $data['data']); - } - - public function testInstagramProfileWithBio() { - $url = 'https://www.instagram.com/pk_spam/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertSame([ - 'type' => 'card', - 'name' => 'pk_spam', - 'nickname' => 'pk_spam', - 'url' => 'https://www.instagram.com/pk_spam/', - 'photo' => 'https://scontent-frx5-1.cdninstagram.com/vp/74112f515c64726429c69fedcb927c2d/5CB64CF1/t51.2885-19/44884218_345707102882519_2446069589734326272_n.jpg?_nc_ht=scontent-frx5-1.cdninstagram.com', - 'note' => 'My website is https://aaronparecki.com.dev/ and http://aaronpk.micro.blog/about/ and https://tiny.xyz.dev/' - ], $data['data']); - } - - public function testInstagramProfileFeed() { - $url = 'https://www.instagram.com/pk_spam/'; - $response = $this->parse(['url' => $url, 'expect' => 'feed']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals('feed', $data['data']['type']); - $this->assertEquals(12, count($data['data']['items'])); - $this->assertEquals('https://www.instagram.com/p/BsdlOmLh_IX/', $data['data']['items'][0]['url']); - $this->assertEquals('https://www.instagram.com/p/BGFdtAViMJy/', $data['data']['items'][11]['url']); - } - - public function testInstagramPhotoWithAltText() { - $url = 'https://www.instagram.com/p/BsdjKytBZyx/'; - - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals('Pink text on a white background that says "Photo with alt text"', $data['data']['meta']['https://instagram.fsjc1-3.fna.fbcdn.net/vp/a7e61adf3d84f07863ffdb99f0fdcc86/5CD9B7F3/t51.2885-15/e35/47692478_2276538359047529_8318084305806697090_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net']['alt']); - } - - public function testInstagramMultiPhotoWithAltText() { - $url = 'https://www.instagram.com/p/BsdlOmLh_IX/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals('A large pink "1" in a circle with a small green "2" behind it', $data['data']['meta']['https://instagram.fsjc1-3.fna.fbcdn.net/vp/90bf019b7396d7bc2b1ee02170902a2e/5CCC9B87/t51.2885-15/e35/47692921_321791688431421_3314633848293773579_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net']['alt']); - $this->assertEquals('A large green "2" in a circle with a small pink "1" behind it', $data['data']['meta']['https://instagram.fsjc1-3.fna.fbcdn.net/vp/a6c93d8fcd5ad0e3b60f2ac0695eb34e/5CC3898E/t51.2885-15/e35/49663055_349750985612151_2949260446582336214_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net']['alt']); - } - - public function testInstagramPhotoAutogeneratedAltText() { - $url = 'https://www.instagram.com/p/Bq8U12UAcdq/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals(200, $data['code']); - $this->assertEquals('instagram', $data['source-format']); - - $this->assertEquals('Image may contain: one or more people and hat', $data['data']['meta']['https://instagram.fsjc1-3.fna.fbcdn.net/vp/7f8954f33de897c0c57656b798637f4c/5CC3DF9F/t51.2885-15/e35/45605085_1989380037822519_4707213851165118070_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net']['alt']); - } +class InstagramTest extends PHPUnit\Framework\TestCase +{ + + private $http; + + public function setUp(): void + { + $this->client = new Parse(); + $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); + $this->client->mc = null; + } + + private function parse($params) + { + $request = new Request($params); + $response = new Response(); + return $this->client->parse($request, $response); + } + + public function testInstagramPhoto() + { + // Original URL: https://www.instagram.com/p/BO5rYVElvJq/ + $url = 'https://www.instagram.com/p/BO5rYVElvJq/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('photo', $data['data']['post-type']); + $this->assertEquals('2017-01-05T23:31:32+00:00', $data['data']['published']); + $this->assertContains('planning', $data['data']['category']); + $this->assertContains('2017', $data['data']['category']); + $this->assertEquals('Kind of crazy to see the whole year laid out like this. #planning #2017', $data['data']['content']['text']); + $this->assertEquals(1, count($data['data']['photo'])); + $this->assertEquals(['https://instagram.fsjc1-3.fna.fbcdn.net/vp/af9471f885e6197478d71807a7cbf297/5CBA6E5F/t51.2885-15/e35/15803256_1832278043695907_4846092951052353536_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net'], $data['data']['photo']); + $this->assertEquals('https://www.instagram.com/aaronpk/', $data['data']['author']['url']); + $this->assertEquals('Aaron Parecki', $data['data']['author']['name']); + $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/a2909937316893f18760f1077ca88fa1/5CBB520A/t51.2885-19/s150x150/14240576_268350536897085_1129715662_a.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['author']['photo']); + $this->assertArrayNotHasKey('meta', $data['data']); // make sure this does not include alt text (autogenerated placeholder from instagram) + } + + public function testBGDpqNoiMJ0() + { + // https://www.instagram.com/p/BGDpqNoiMJ0/ + $url = 'http://www.instagram.com/BGDpqNoiMJ0'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('photo', $data['data']['post-type']); + $this->assertSame( + [ + 'type' => 'card', + 'name' => 'pk_spam', + 'nickname' => 'pk_spam', + 'url' => 'https://www.instagram.com/pk_spam/', + 'photo' => 'https://scontent-frx5-1.cdninstagram.com/vp/f17e1275a70fc32e93cbf434ddc32bcd/5B6CCC7A/t51.2885-19/11906329_960233084022564_1448528159_a.jpg', + ], $data['data']['author'] + ); + + $this->assertSame( + [ + 'muffins', + 'https://www.instagram.com/indiewebcat/' + ], $data['data']['category'] + ); + + $this->assertEquals('Meow #muffins', $data['data']['content']['text']); + $this->assertSame(['https://instagram.fsea1-1.fna.fbcdn.net/vp/9433ea494a8b055bebabf70fd81cfa32/5B51F092/t51.2885-15/e35/13266755_877794672348882_1908663476_n.jpg'], $data['data']['photo']); + $this->assertEquals('2016-05-30T20:46:22-07:00', $data['data']['published']); + + $this->assertEquals('https://www.instagram.com/explore/locations/359000003/', $data['data']['location'][0]); + + $this->assertSame( + [ + 'type' => 'card', + 'name' => 'Burnside 26', + 'url' => 'https://www.instagram.com/explore/locations/359000003/', + 'latitude' => 45.52322, + 'longitude' => -122.63885 + ], $data['data']['refs']['https://www.instagram.com/explore/locations/359000003/'] + ); + } + + public function testInstagramVideo() + { + // Original URL: https://www.instagram.com/p/BO_RN8AFZSx/ + $url = 'https://www.instagram.com/p/BO_RN8AFZSx/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('video', $data['data']['post-type']); + $this->assertContains('100daysofmusic', $data['data']['category']); + $this->assertEquals('Day 18. Maple and Spruce #100daysofmusic #100daysproject #the100dayproject https://aaronparecki.com/2017/01/07/14/day18', $data['data']['content']['text']); + $this->assertEquals(1, count($data['data']['photo'])); + $this->assertEquals(['https://instagram.fsjc1-3.fna.fbcdn.net/vp/a77f8672f977413d2eb5239cd6d5c4cf/5C3A4ADF/t51.2885-15/e15/15624670_548881701986735_8264383763249627136_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net'], $data['data']['photo']); + $this->assertEquals(1, count($data['data']['video'])); + $this->assertEquals(['https://instagram.fsjc1-3.fna.fbcdn.net/vp/90ed8fe576cba16e258c0f4cfc05299a/5C3A129E/t50.2886-16/15921147_1074837002642259_2269307616507199488_n.mp4?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net'], $data['data']['video']); + $this->assertEquals('https://www.instagram.com/aaronpk/', $data['data']['author']['url']); + $this->assertEquals('Aaron Parecki', $data['data']['author']['name']); + $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/a2909937316893f18760f1077ca88fa1/5CBB520A/t51.2885-19/s150x150/14240576_268350536897085_1129715662_a.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['author']['photo']); + } + + public function testInstagramPhotoWithPersonTag() + { + // Original URL: https://www.instagram.com/p/BNfqVfVlmkj/ + $url = 'https://www.instagram.com/p/BNfqVfVlmkj/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals(2, count($data['data']['category'])); + $this->assertEquals(['type'=>'card','name'=>'KmikeyM™️','nickname'=>'kmikeym','url'=>'https://www.instagram.com/kmikeym/','photo'=>'https://instagram.fsjc1-3.fna.fbcdn.net/vp/ea5b988b616dbcc778b3013bf2426d70/5CCAC7FC/t51.2885-19/s320x320/20634957_814691788710973_2275383796935163904_a.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net','note'=>"The world’s first publicly traded person.\n•\nAcct in collaboration with @norbertoinc\n•\nBecome a shareholder today!\n•"], $data['data']['refs']['https://www.instagram.com/kmikeym/']); + $this->assertContains('https://www.instagram.com/kmikeym/', $data['data']['category']); + $this->assertArrayHasKey('https://www.instagram.com/kmikeym/', $data['data']['refs']); + } + + public function testInstagramPhotoWithVenue() + { + // Original URL: https://www.instagram.com/p/BN3Z5salSys/ + $url = 'https://www.instagram.com/p/BN3Z5salSys/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals(1, count($data['data']['location'])); + $this->assertContains('https://www.instagram.com/explore/locations/109284789535230/', $data['data']['location']); + $this->assertArrayHasKey('https://www.instagram.com/explore/locations/109284789535230/', $data['data']['refs']); + $venue = $data['data']['refs']['https://www.instagram.com/explore/locations/109284789535230/']; + $this->assertEquals('XOXO Outpost', $venue['name']); + $this->assertEquals('45.5261002', $venue['latitude']); + $this->assertEquals('-122.6558081', $venue['longitude']); + // Setting a venue should set the timezone + $this->assertEquals('2016-12-10T21:48:56-08:00', $data['data']['published']); + } + + public function testTwoPhotos() + { + // Original URL: https://www.instagram.com/p/BZWmUB_DVtp/ + $url = 'https://www.instagram.com/p/BZWmUB_DVtp/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals(2, count($data['data']['photo'])); + $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/6b09c3d5490ee3efb55849858a9ec014/5CBFBC38/t51.2885-15/e35/21827424_134752690591737_8093088291252862976_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][0]); + $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/8b1b2e6efa86a4856ec37a60f0fa77f5/5CC2D34D/t51.2885-15/e35/21909774_347707439021016_5237540582556958720_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][1]); + $this->assertArrayNotHasKey('video', $data['data']); + $this->assertEquals(2, count($data['data']['category'])); + $this->assertArrayNotHasKey('meta', $data['data']); + } + + public function testMixPhotosAndVideos() + { + // Original URL: https://www.instagram.com/p/BZWmpecjBwN/ + $url = 'https://www.instagram.com/p/BZWmpecjBwN/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals('photo', $data['data']['post-type']); // we discard videos in this case right now + $this->assertEquals(3, count($data['data']['photo'])); + $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/ee1a28763918069f3e54dad35be24ad8/5CCFBAB8/t51.2885-15/e35/21878922_686481254874005_8468823712617988096_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][0]); + $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/ddc0ebe969bb1f9e6bf8adada0892c90/5C39EBC9/t51.2885-15/e15/21910026_1507234999368159_6974261907783942144_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][1]); + $this->assertEquals('https://instagram.fsjc1-3.fna.fbcdn.net/vp/bfe032af795427443ea448840df1c3a4/5CCC8C88/t51.2885-15/e35/21878800_273567963151023_7672178549897297920_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', $data['data']['photo'][2]); + $this->assertArrayNotHasKey('video', $data['data']); + $this->assertEquals(2, count($data['data']['category'])); + } + + public function testInstagramProfile() + { + $url = 'https://www.instagram.com/aaronpk/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertSame( + [ + 'type' => 'card', + 'name' => 'Aaron Parecki', + 'nickname' => 'aaronpk', + 'url' => 'https://www.instagram.com/aaronpk/', + 'photo' => 'https://instagram.fsjc1-3.fna.fbcdn.net/vp/45aee453740a714bf408f8947f89da8e/5CCB4B8E/t51.2885-19/s320x320/14240576_268350536897085_1129715662_a.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net', + 'note' => '🔒 oauth.net 🎥 backpedal.tv 🎙 streampdx.com 📡 w7apk.com' + ], $data['data'] + ); + } + + public function testInstagramProfileWithBio() + { + $url = 'https://www.instagram.com/pk_spam/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertSame( + [ + 'type' => 'card', + 'name' => 'pk_spam', + 'nickname' => 'pk_spam', + 'url' => 'https://www.instagram.com/pk_spam/', + 'photo' => 'https://scontent-frx5-1.cdninstagram.com/vp/74112f515c64726429c69fedcb927c2d/5CB64CF1/t51.2885-19/44884218_345707102882519_2446069589734326272_n.jpg?_nc_ht=scontent-frx5-1.cdninstagram.com', + 'note' => 'My website is https://aaronparecki.com.dev/ and http://aaronpk.micro.blog/about/ and https://tiny.xyz.dev/' + ], $data['data'] + ); + } + + public function testInstagramProfileFeed() + { + $url = 'https://www.instagram.com/pk_spam/'; + $response = $this->parse(['url' => $url, 'expect' => 'feed']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals('feed', $data['data']['type']); + $this->assertEquals(12, count($data['data']['items'])); + $this->assertEquals('https://www.instagram.com/p/BsdlOmLh_IX/', $data['data']['items'][0]['url']); + $this->assertEquals('https://www.instagram.com/p/BGFdtAViMJy/', $data['data']['items'][11]['url']); + } + + public function testInstagramPhotoWithAltText() + { + $url = 'https://www.instagram.com/p/BsdjKytBZyx/'; + + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals('Pink text on a white background that says "Photo with alt text"', $data['data']['meta']['https://instagram.fsjc1-3.fna.fbcdn.net/vp/a7e61adf3d84f07863ffdb99f0fdcc86/5CD9B7F3/t51.2885-15/e35/47692478_2276538359047529_8318084305806697090_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net']['alt']); + } + + public function testInstagramMultiPhotoWithAltText() + { + $url = 'https://www.instagram.com/p/BsdlOmLh_IX/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals('A large pink "1" in a circle with a small green "2" behind it', $data['data']['meta']['https://instagram.fsjc1-3.fna.fbcdn.net/vp/90bf019b7396d7bc2b1ee02170902a2e/5CCC9B87/t51.2885-15/e35/47692921_321791688431421_3314633848293773579_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net']['alt']); + $this->assertEquals('A large green "2" in a circle with a small pink "1" behind it', $data['data']['meta']['https://instagram.fsjc1-3.fna.fbcdn.net/vp/a6c93d8fcd5ad0e3b60f2ac0695eb34e/5CC3898E/t51.2885-15/e35/49663055_349750985612151_2949260446582336214_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net']['alt']); + } + + public function testInstagramPhotoAutogeneratedAltText() + { + $url = 'https://www.instagram.com/p/Bq8U12UAcdq/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals(200, $data['code']); + $this->assertEquals('instagram', $data['source-format']); + + $this->assertEquals('Image may contain: one or more people and hat', $data['data']['meta']['https://instagram.fsjc1-3.fna.fbcdn.net/vp/7f8954f33de897c0c57656b798637f4c/5CC3DF9F/t51.2885-15/e35/45605085_1989380037822519_4707213851165118070_n.jpg?_nc_ht=instagram.fsjc1-3.fna.fbcdn.net']['alt']); + } } diff --git a/tests/LibraryTest.php b/tests/LibraryTest.php index 5e0109c..15f3883 100644 --- a/tests/LibraryTest.php +++ b/tests/LibraryTest.php @@ -1,67 +1,74 @@

    Hello World

    '; - $mf2 = Mf2\parse($html, 'http://example.com/entry'); + public function testInputIsParsedMf2Array() + { + $html = '

    Hello World

    '; + $mf2 = Mf2\parse($html, 'http://example.com/entry'); - $xray = new p3k\XRay(); - $data = $xray->process('http://example.com/entry', $mf2); + $xray = new p3k\XRay(); + $data = $xray->process('http://example.com/entry', $mf2); - $this->assertEquals('Hello World', $data['data']['content']['text']); - $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]); - } + $this->assertEquals('Hello World', $data['data']['content']['text']); + $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]); + } - public function testInputIsParsedMf2JSON() { - $html = '

    Hello World

    '; - $mf2 = Mf2\parse($html, 'http://example.com/entry'); + public function testInputIsParsedMf2JSON() + { + $html = '

    Hello World

    '; + $mf2 = Mf2\parse($html, 'http://example.com/entry'); - $xray = new p3k\XRay(); - $data = $xray->process('http://example.com/entry', json_encode($mf2)); + $xray = new p3k\XRay(); + $data = $xray->process('http://example.com/entry', json_encode($mf2)); - $this->assertEquals('Hello World', $data['data']['content']['text']); - $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]); - } + $this->assertEquals('Hello World', $data['data']['content']['text']); + $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]); + } - public function testInputIsParsedMf2HCard() { - $url = 'https://waterpigs.co.uk/'; - $html = 'Barnaby Walters'; - $mf2 = Mf2\parse($html, $url); + public function testInputIsParsedMf2HCard() + { + $url = 'https://waterpigs.co.uk/'; + $html = 'Barnaby Walters'; + $mf2 = Mf2\parse($html, $url); - $xray = new p3k\XRay(); - $data = $xray->process($url, $mf2); - $this->assertEquals('card', $data['data']['type']); - $this->assertEquals('Barnaby Walters', $data['data']['name']); - } + $xray = new p3k\XRay(); + $data = $xray->process($url, $mf2); + $this->assertEquals('card', $data['data']['type']); + $this->assertEquals('Barnaby Walters', $data['data']['name']); + } - public function testNoHEntryMarkupMF2JSON() { - $url = 'http://example.com/'; - $html = '

    Target

    '; - $mf2 = Mf2\parse($html, $url); + public function testNoHEntryMarkupMF2JSON() + { + $url = 'http://example.com/'; + $html = '

    Target

    '; + $mf2 = Mf2\parse($html, $url); - $xray = new p3k\XRay(); - $data = $xray->process($url, $mf2); - $this->assertEquals('unknown', $data['data']['type']); - } + $xray = new p3k\XRay(); + $data = $xray->process($url, $mf2); + $this->assertEquals('unknown', $data['data']['type']); + } - public function testNoHEntryMarkup() { - $url = 'http://example.com/'; - $html = '

    Target

    '; + public function testNoHEntryMarkup() + { + $url = 'http://example.com/'; + $html = '

    Target

    '; - $xray = new p3k\XRay(); - $data = $xray->parse($url, $html); - $this->assertEquals('unknown', $data['data']['type']); - } + $xray = new p3k\XRay(); + $data = $xray->parse($url, $html); + $this->assertEquals('unknown', $data['data']['type']); + } - public function testNoHEntryMarkupWithTarget() { - $url = 'http://example.com/'; - $html = '

    Target

    '; + public function testNoHEntryMarkupWithTarget() + { + $url = 'http://example.com/'; + $html = '

    Target

    '; - $xray = new p3k\XRay(); - $data = $xray->parse($url, $html, ['target' => 'http://target.example.com/']); - $this->assertEquals('unknown', $data['data']['type']); - $this->assertArrayNotHasKey('error', $data); - $this->assertArrayNotHasKey('html', $data); - } + $xray = new p3k\XRay(); + $data = $xray->parse($url, $html, ['target' => 'http://target.example.com/']); + $this->assertEquals('unknown', $data['data']['type']); + $this->assertArrayNotHasKey('error', $data); + $this->assertArrayNotHasKey('html', $data); + } } diff --git a/tests/MediaTypeTest.php b/tests/MediaTypeTest.php index 0f05b20..ceb2c07 100644 --- a/tests/MediaTypeTest.php +++ b/tests/MediaTypeTest.php @@ -1,44 +1,50 @@ assertEquals('text', $type->type); - $this->assertEquals('html', $type->subtype); - $this->assertEquals('html', $type->format); - $this->assertEquals(null, $type->charset); - } + public function testParseTextHtml() + { + $type = new p3k\XRay\MediaType('text/html'); + $this->assertEquals('text', $type->type); + $this->assertEquals('html', $type->subtype); + $this->assertEquals('html', $type->format); + $this->assertEquals(null, $type->charset); + } - public function testParseTextHtmlUtf8() { - $type = new p3k\XRay\MediaType('text/html; charset=UTF-8'); - $this->assertEquals('text', $type->type); - $this->assertEquals('html', $type->subtype); - $this->assertEquals('html', $type->format); - $this->assertEquals('UTF-8', $type->charset); - } + public function testParseTextHtmlUtf8() + { + $type = new p3k\XRay\MediaType('text/html; charset=UTF-8'); + $this->assertEquals('text', $type->type); + $this->assertEquals('html', $type->subtype); + $this->assertEquals('html', $type->format); + $this->assertEquals('UTF-8', $type->charset); + } - public function testParseTextHtmlUtf8Extra() { - $type = new p3k\XRay\MediaType('text/html; hello=world; charset=UTF-8'); - $this->assertEquals('text', $type->type); - $this->assertEquals('html', $type->subtype); - $this->assertEquals('html', $type->format); - $this->assertEquals('UTF-8', $type->charset); - } + public function testParseTextHtmlUtf8Extra() + { + $type = new p3k\XRay\MediaType('text/html; hello=world; charset=UTF-8'); + $this->assertEquals('text', $type->type); + $this->assertEquals('html', $type->subtype); + $this->assertEquals('html', $type->format); + $this->assertEquals('UTF-8', $type->charset); + } - public function testParseApplicationJson() { - $type = new p3k\XRay\MediaType('application/json'); - $this->assertEquals('application', $type->type); - $this->assertEquals('json', $type->subtype); - $this->assertEquals('json', $type->format); - $this->assertEquals(null, $type->charset); - } + public function testParseApplicationJson() + { + $type = new p3k\XRay\MediaType('application/json'); + $this->assertEquals('application', $type->type); + $this->assertEquals('json', $type->subtype); + $this->assertEquals('json', $type->format); + $this->assertEquals(null, $type->charset); + } - public function testParseApplicationJsonFeed() { - $type = new p3k\XRay\MediaType('application/feed+json'); - $this->assertEquals('application', $type->type); - $this->assertEquals('feed+json', $type->subtype); - $this->assertEquals('json', $type->format); - $this->assertEquals(null, $type->charset); - } + public function testParseApplicationJsonFeed() + { + $type = new p3k\XRay\MediaType('application/feed+json'); + $this->assertEquals('application', $type->type); + $this->assertEquals('feed+json', $type->subtype); + $this->assertEquals('json', $type->format); + $this->assertEquals(null, $type->charset); + } } diff --git a/tests/ParseTest.php b/tests/ParseTest.php index 1032d8c..1af1491 100644 --- a/tests/ParseTest.php +++ b/tests/ParseTest.php @@ -2,1211 +2,1313 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class ParseTest extends PHPUnit_Framework_TestCase { - - private $http; - - public function setUp() { - $this->client = new Parse(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->parse($request, $response); - } - - public function testMissingURL() { - $response = $this->parse([]); - - $body = $response->getContent(); - $this->assertEquals(400, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('missing_url', $data->error); - } - - public function testInvalidURL() { - $url = 'ftp://example.com/foo'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(400, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('invalid_url', $data->error); - } - - public function testTargetNotFound() { - $url = 'http://source.example.com/basictest'; - $response = $this->parse(['url' => $url, 'target' => 'http://example.net']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('no_link_found', $data->error); - $this->assertEquals('200', $data->code); - $this->assertEquals($url, $data->url); - } - - public function testTargetFound() { - $url = 'http://source.example.com/basictest'; - $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - } - - public function testTargetNotFoundInXML() { - $url = 'http://feed.example.com/atom'; - $response = $this->parse(['url' => $url, 'target' => 'http://example.net']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('no_link_found', $data->error); - $this->assertEquals('200', $data->code); - $this->assertEquals($url, $data->url); - } - - public function testHTMLContent() { - $url = 'http://source.example.com/html-content'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('name', $data->data); - $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->text); - $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->html); - } - - public function testContentFromJSONOnlyPlaintext() { - $mf2JSON = json_encode([ - 'items' => [[ - 'type' => ['h-entry'], - 'properties' => [ - 'content' => [ +class ParseTest extends PHPUnit\Framework\TestCase +{ + + private $http; + + public function setUp(): void + { + $this->client = new Parse(); + $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); + $this->client->mc = null; + } + + private function parse($params) + { + $request = new Request($params); + $response = new Response(); + return $this->client->parse($request, $response); + } + + public function testMissingURL() + { + $response = $this->parse([]); + + $body = $response->getContent(); + $this->assertEquals(400, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('missing_url', $data->error); + } + + public function testInvalidURL() + { + $url = 'ftp://example.com/foo'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(400, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('invalid_url', $data->error); + } + + public function testTargetNotFound() + { + $url = 'http://source.example.com/basictest'; + $response = $this->parse(['url' => $url, 'target' => 'http://example.net']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('no_link_found', $data->error); + $this->assertEquals('200', $data->code); + $this->assertEquals($url, $data->url); + } + + public function testTargetFound() + { + $url = 'http://source.example.com/basictest'; + $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + } + + public function testTargetNotFoundInXML() + { + $url = 'http://feed.example.com/atom'; + $response = $this->parse(['url' => $url, 'target' => 'http://example.net']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('no_link_found', $data->error); + $this->assertEquals('200', $data->code); + $this->assertEquals($url, $data->url); + } + + public function testHTMLContent() + { + $url = 'http://source.example.com/html-content'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('name', $data->data); + $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->text); + $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->html); + } + + public function testContentFromJSONOnlyPlaintext() + { + $mf2JSON = json_encode( + [ + 'items' => [[ + 'type' => ['h-entry'], + 'properties' => [ + 'content' => [ 'plaintext' - ] - ] - ]] - ]); - $xray = new \p3k\XRay(); - $parsed = $xray->process(false, $mf2JSON); - $this->assertEquals('mf2+json', $parsed['source-format']); - $item = $parsed['data']; - $this->assertEquals('entry', $item['type']); - $this->assertEquals('note', $item['post-type']); - $this->assertEquals('plaintext', $item['content']['text']); - $this->assertArrayNotHasKey('html', $item['content']); - } - - public function testHTMLContentFromJSONNoPlaintext() { - $mf2JSON = json_encode([ - 'items' => [[ - 'type' => ['h-entry'], - 'properties' => [ - 'content' => [[ + ] + ] + ]] + ] + ); + $xray = new \p3k\XRay(); + $parsed = $xray->process(false, $mf2JSON); + $this->assertEquals('mf2+json', $parsed['source-format']); + $item = $parsed['data']; + $this->assertEquals('entry', $item['type']); + $this->assertEquals('note', $item['post-type']); + $this->assertEquals('plaintext', $item['content']['text']); + $this->assertArrayNotHasKey('html', $item['content']); + } + + public function testHTMLContentFromJSONNoPlaintext() + { + $mf2JSON = json_encode( + [ + 'items' => [[ + 'type' => ['h-entry'], + 'properties' => [ + 'content' => [[ 'html' => 'bold italic text' - ]] - ] - ]] - ]); - $xray = new \p3k\XRay(); - $parsed = $xray->process(false, $mf2JSON); - $this->assertEquals('mf2+json', $parsed['source-format']); - $item = $parsed['data']; - $this->assertEquals('entry', $item['type']); - $this->assertEquals('note', $item['post-type']); - $this->assertEquals('bold italic text', $item['content']['text']); - $this->assertEquals('bold italic text', $item['content']['html']); - } - - public function testHTMLContentFromJSONEmptyTags() { - $mf2JSON = json_encode([ - 'items' => [[ - 'type' => ['h-entry'], - 'properties' => [ - 'content' => [[ + ]] + ] + ]] + ] + ); + $xray = new \p3k\XRay(); + $parsed = $xray->process(false, $mf2JSON); + $this->assertEquals('mf2+json', $parsed['source-format']); + $item = $parsed['data']; + $this->assertEquals('entry', $item['type']); + $this->assertEquals('note', $item['post-type']); + $this->assertEquals('bold italic text', $item['content']['text']); + $this->assertEquals('bold italic text', $item['content']['html']); + } + + public function testHTMLContentFromJSONEmptyTags() + { + $mf2JSON = json_encode( + [ + 'items' => [[ + 'type' => ['h-entry'], + 'properties' => [ + 'content' => [[ 'html' => '' - ]] - ] - ]] - ]); - $xray = new \p3k\XRay(); - $parsed = $xray->process(false, $mf2JSON); - $this->assertEquals('mf2+json', $parsed['source-format']); - $item = $parsed['data']; - $this->assertEquals('entry', $item['type']); - $this->assertEquals('note', $item['post-type']); - $this->assertArrayNotHasKey('content', $item); - } - - public function testHTMLContentFromJSONContentMismatch() { - $mf2JSON = json_encode([ - 'items' => [[ - 'type' => ['h-entry'], - 'properties' => [ - 'content' => [[ + ]] + ] + ]] + ] + ); + $xray = new \p3k\XRay(); + $parsed = $xray->process(false, $mf2JSON); + $this->assertEquals('mf2+json', $parsed['source-format']); + $item = $parsed['data']; + $this->assertEquals('entry', $item['type']); + $this->assertEquals('note', $item['post-type']); + $this->assertArrayNotHasKey('content', $item); + } + + public function testHTMLContentFromJSONContentMismatch() + { + $mf2JSON = json_encode( + [ + 'items' => [[ + 'type' => ['h-entry'], + 'properties' => [ + 'content' => [[ 'value' => 'foo', 'html' => 'bar' - ]] - ] - ]] - ]); - $xray = new \p3k\XRay(); - $parsed = $xray->process(false, $mf2JSON); - $this->assertEquals('mf2+json', $parsed['source-format']); - $item = $parsed['data']; - $this->assertEquals('entry', $item['type']); - $this->assertEquals('note', $item['post-type']); - $this->assertEquals('bar', $item['content']['text']); - $this->assertEquals('bar', $item['content']['html']); - } - - public function testHTMLContentFromJSONNoHTML() { - $mf2JSON = json_encode([ - 'items' => [[ - 'type' => ['h-entry'], - 'properties' => [ - 'content' => [[ + ]] + ] + ]] + ] + ); + $xray = new \p3k\XRay(); + $parsed = $xray->process(false, $mf2JSON); + $this->assertEquals('mf2+json', $parsed['source-format']); + $item = $parsed['data']; + $this->assertEquals('entry', $item['type']); + $this->assertEquals('note', $item['post-type']); + $this->assertEquals('bar', $item['content']['text']); + $this->assertEquals('bar', $item['content']['html']); + } + + public function testHTMLContentFromJSONNoHTML() + { + $mf2JSON = json_encode( + [ + 'items' => [[ + 'type' => ['h-entry'], + 'properties' => [ + 'content' => [[ 'value' => 'foo', - ]] - ] - ]] - ]); - $xray = new \p3k\XRay(); - $parsed = $xray->process(false, $mf2JSON); - $this->assertEquals('mf2+json', $parsed['source-format']); - $item = $parsed['data']; - $this->assertEquals('entry', $item['type']); - $this->assertEquals('note', $item['post-type']); - $this->assertArrayNotHasKey('content', $item); - } - - public function testFindTargetLinkIsImage() { - $url = 'http://source.example.com/link-is-img'; - $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com/photo.jpg']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertEquals('photo', $data->data->{'post-type'}); - $this->assertObjectNotHasAttribute('name', $data->data); - $this->assertEquals('This page has an img tag with the target URL.', $data->data->content->text); - } - - public function testFindTargetLinkIsVideo() { - $url = 'http://source.example.com/link-is-video'; - $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com/movie.mp4']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertEquals('video', $data->data->{'post-type'}); - $this->assertObjectNotHasAttribute('name', $data->data); - $this->assertEquals('This page has a video tag with the target URL.', $data->data->content->text); - } - - public function testFindTargetLinkIsAudio() { - $url = 'http://source.example.com/link-is-audio'; - $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com/media.mp3']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertEquals('audio', $data->data->{'post-type'}); - $this->assertObjectNotHasAttribute('name', $data->data); - $this->assertEquals('This page has an audio tag with the target URL.', $data->data->content->text); - } - - public function testFindTargetLinkInFeed() { - $url = 'http://feed.example.com/jsonfeed'; - $response = $this->parse(['url' => $url, 'target' => 'http://www.manton.org/2017/11/5993.html']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - } - - public function testFindTargetLinkInHTMLInFeed() { - $url = 'http://feed.example.com/jsonfeed'; - $response = $this->parse(['url' => $url, 'target' => 'http://www.manton.org/2016/11/todays-social-networks-are-broken.html']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - } - - public function testNotFindTargetLinkInHTMLInFeed() { - $url = 'http://feed.example.com/jsonfeed'; - $response = $this->parse(['url' => $url, 'target' => 'http://example.com/']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectHasAttribute('error', $data); - $this->assertEquals('no_link_found', $data->error); - } - - public function testFindRelativeTargetLink() { - $url = 'http://source.example.com/multiple-urls'; - $response = $this->parse(['url' => $url, 'target' => 'http://source.example.com/photo.jpg']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - } - - public function testTextContent() { - $url = 'http://source.example.com/text-content'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertObjectNotHasAttribute('name', $data->data); - $this->assertEquals('This page has a link to target.example.com and some formatted text but is in a p-content element so is plaintext.', $data->data->content->text); - } - - public function testArticleWithFeaturedImage() { - $url = 'http://source.example.com/article-with-featured-image'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertEquals('article', $data->data->{'post-type'}); - $this->assertEquals('Post Title', $data->data->name); - $this->assertEquals('This is a blog post.', $data->data->content->text); - $this->assertEquals('http://source.example.com/featured.jpg', $data->data->featured); - } - - public function testContentWithPrefixedName() { - $url = 'http://source.example.com/content-with-prefixed-name'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertObjectNotHasAttribute('name', $data->data); - $this->assertEquals('note', $data->data->{'post-type'}); - $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->text); - $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->html); - } - - public function testContentWithDistinctName() { - $url = 'http://source.example.com/content-with-distinct-name'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertEquals('Hello World', $data->data->name); - $this->assertEquals('article', $data->data->{'post-type'}); - $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->text); - $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->html); - } - - public function testNameWithNoContent() { - $url = 'http://source.example.com/name-no-content'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertEquals('Hello World', $data->data->name); - $this->assertEquals('article', $data->data->{'post-type'}); - $this->assertObjectNotHasAttribute('content', $data->data); - } - - public function testEntryWithDuplicateCategories() { - $url = 'http://source.example.com/h-entry-duplicate-categories'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertEquals(['indieweb'], $data->data->category); - } - - public function testEntryStripHashtagWithDuplicateCategories() { - $url = 'http://source.example.com/h-entry-strip-hashtag-from-categories'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertContains('indieweb', $data->data->category); - $this->assertContains('xray', $data->data->category); - $this->assertEquals(2, count($data->data->category)); - } - - public function testNoHEntryMarkup() { - $url = 'http://source.example.com/no-h-entry'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('unknown', $data->data->type); - $this->assertObjectNotHasAttribute('html', $data); - } - - public function testFindTargetInNoParsedResult() { - $url = 'http://source.example.com/no-h-entry'; - $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertObjectNotHasAttribute('error', $data); - $this->assertEquals('unknown', $data->data->type); - } - - public function testReplyIsURL() { - $url = 'http://source.example.com/reply-is-url'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('http://example.com/100', $data['data']['in-reply-to'][0]); - } - - public function testReplyIsHCite() { - $url = 'http://source.example.com/reply-is-h-cite'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('reply', $data['data']['post-type']); - $this->assertEquals('http://example.com/100', $data['data']['in-reply-to'][0]); - $this->assertArrayHasKey('http://example.com/100', $data['data']['refs']); - $this->assertEquals('Example Post', $data['data']['refs']['http://example.com/100']['name']); - $this->assertEquals('http://example.com/100', $data['data']['refs']['http://example.com/100']['url']); - } - - public function testPersonTagIsURL() { - $url = 'http://source.example.com/person-tag-is-url'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('http://alice.example.com/', $data['data']['category'][0]); - } - - public function testPersonTagIsHCard() { - $url = 'http://source.example.com/person-tag-is-h-card'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('http://alice.example.com/', $data['data']['category'][0]); - $this->assertArrayHasKey('http://alice.example.com/', $data['data']['refs']); - $this->assertEquals('card', $data['data']['refs']['http://alice.example.com/']['type']); - $this->assertEquals('http://alice.example.com/', $data['data']['refs']['http://alice.example.com/']['url']); - $this->assertEquals('Alice', $data['data']['refs']['http://alice.example.com/']['name']); - } - - public function testSyndicationIsURL() { - $url = 'http://source.example.com/has-syndication'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('http://syndicated.example/', $data['data']['syndication'][0]); - } - - public function testHEntryNoContent() { - $url = 'http://source.example.com/h-entry-no-content'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertObjectNotHasAttribute('content', $data->data); - $this->assertEquals('This is a Post', $data->data->name); - } - - public function testHEntryIsNotFirstObject() { - $url = 'http://source.example.com/h-entry-is-not-first'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('Hello World', $data['data']['content']['text']); - } - - public function testHEntryRSVP() { - $url = 'http://source.example.com/h-entry-rsvp'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('rsvp', $data['data']['post-type']); - $this->assertEquals('I\'ll be there!', $data['data']['content']['text']); - $this->assertEquals('yes', $data['data']['rsvp']); - } - - public function testMultipleHEntryOnPermalink() { - $url = 'http://source.example.com/multiple-h-entry-on-permalink'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('Primary Post', $data['data']['name']); - } - - public function testHEntryWithHCardBeforeIt() { - $url = 'http://source.example.com/h-entry-with-h-card-before-it'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('Hello World', $data['data']['content']['text']); - } - - public function testHEntryWithHCardSibling() { - $url = 'http://source.example.com/h-entry-with-h-card-sibling'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('Hello World', $data['data']['content']['text']); - } - - public function testHEntryWithTwoHCardsBeforeIt() { - $url = 'http://source.example.com/h-entry-with-two-h-cards-before-it'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('Hello World', $data['data']['content']['text']); - } - - public function testHEntryRedirectWithHCardSibling() { - $url = 'http://source.example.com/h-entry-redirect-with-h-card-sibling'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('Hello World', $data['data']['content']['text']); - } - - public function testSingleHEntryHasNoPermalink() { - $url = 'http://source.example.com/single-h-entry-has-no-permalink'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('Hello World', $data['data']['content']['text']); - } - - public function testBridgyExampleWithNoMatchingURL() { - $url = 'http://source.example.com/bridgy-example'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - } - - public function testEventWithHTMLDescription() { - $url = 'http://source.example.com/h-event'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('event', $data['data']['type']); - $this->assertEquals('event', $data['data']['post-type']); - $this->assertEquals('Homebrew Website Club', $data['data']['name']); - $this->assertEquals($url, $data['data']['url']); - $this->assertEquals('2016-03-09T18:30', $data['data']['start']); - $this->assertEquals('2016-03-09T19:30', $data['data']['end']); - $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['content']['text']); - $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['content']['text']); - $this->assertStringStartsWith("

    Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...

    ", $data['data']['content']['html']); - $this->assertStringEndsWith('

    See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.

    ', $data['data']['content']['html']); - } - - public function testEventWithTextDescription() { - $url = 'http://source.example.com/h-event-text-description'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('event', $data['data']['type']); - $this->assertEquals('event', $data['data']['post-type']); - $this->assertEquals('Homebrew Website Club', $data['data']['name']); - $this->assertEquals($url, $data['data']['url']); - $this->assertEquals('2016-03-09T18:30', $data['data']['start']); - $this->assertEquals('2016-03-09T19:30', $data['data']['end']); - $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['content']['text']); - $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['content']['text']); - $this->assertArrayNotHasKey('html', $data['data']['content']); - } - - public function testEventWithTextContent() { - $url = 'http://source.example.com/h-event-text-content'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('event', $data['data']['type']); - $this->assertEquals('event', $data['data']['post-type']); - $this->assertEquals('Homebrew Website Club', $data['data']['name']); - $this->assertEquals($url, $data['data']['url']); - $this->assertEquals('2016-03-09T18:30', $data['data']['start']); - $this->assertEquals('2016-03-09T19:30', $data['data']['end']); - $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['content']['text']); - $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['content']['text']); - $this->assertArrayNotHasKey('html', $data['data']['content']); - $this->assertEquals('card', $data['data']['author']['type']); - $this->assertEquals('Event Author', $data['data']['author']['name']); - $this->assertEquals('http://source.example.com/', $data['data']['author']['url']); - } - - public function testEventWithHCardLocation() { - $url = 'http://source.example.com/h-event-with-h-card-location'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('event', $data['data']['type']); - $this->assertEquals('event', $data['data']['post-type']); - $this->assertEquals('Homebrew Website Club', $data['data']['name']); - $this->assertEquals($url, $data['data']['url']); - $this->assertEquals('2016-02-09T18:30', $data['data']['start']); - $this->assertEquals('2016-02-09T19:30', $data['data']['end']); - $this->assertEquals('card', $data['data']['location']['type']); - $this->assertEquals('http://source.example.com/venue', $data['data']['location']['url']); - $this->assertEquals('Venue', $data['data']['location']['name']); - $this->assertEquals('45.5', $data['data']['location']['latitude']); - $this->assertEquals('-122.6', $data['data']['location']['longitude']); - $this->assertEquals('1234 Main St', $data['data']['location']['street-address']); - $this->assertEquals('Portland', $data['data']['location']['locality']); - $this->assertEquals('Oregon', $data['data']['location']['region']); - $this->assertEquals('USA', $data['data']['location']['country-name']); - } - - public function testEventWithFeaturedImage() { - $url = 'http://source.example.com/h-event-featured'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('event', $data['data']['type']); - $this->assertEquals('http://source.example.com/featured.jpg', $data['data']['featured']); - } - - public function testMf2ReviewOfProduct() { - $url = 'http://source.example.com/h-review-of-product'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('review', $data['data']['type']); - $this->assertEquals('review', $data['data']['post-type']); - $this->assertEquals('Review', $data['data']['name']); - $this->assertEquals('Not great', $data['data']['summary']); - $this->assertEquals('3', $data['data']['rating']); - $this->assertEquals('5', $data['data']['best']); - $this->assertEquals('This is the full text of the review', $data['data']['content']['text']); - $this->assertContains('red', $data['data']['category']); - $this->assertContains('blue', $data['data']['category']); - $this->assertContains('http://product.example.com/', $data['data']['item']); - $this->assertArrayHasKey('http://product.example.com/', $data['data']['refs']); - $this->assertEquals('product', $data['data']['refs']['http://product.example.com/']['type']); - $this->assertEquals('The Reviewed Product', $data['data']['refs']['http://product.example.com/']['name']); - $this->assertEquals('http://product.example.com/', $data['data']['refs']['http://product.example.com/']['url']); - } - - public function testMf2ReviewOfHCard() { - $url = 'http://source.example.com/h-review-of-h-card'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('review', $data['data']['type']); - $this->assertEquals('review', $data['data']['post-type']); - $this->assertEquals('Review', $data['data']['name']); - $this->assertEquals('Not great', $data['data']['summary']); - $this->assertEquals('3', $data['data']['rating']); - $this->assertEquals('5', $data['data']['best']); - $this->assertEquals('This is the full text of the review', $data['data']['content']['text']); - $this->assertContains('http://business.example.com/', $data['data']['item']); - $this->assertArrayHasKey('http://business.example.com/', $data['data']['refs']); - $this->assertEquals('card', $data['data']['refs']['http://business.example.com/']['type']); - $this->assertEquals('The Reviewed Business', $data['data']['refs']['http://business.example.com/']['name']); - $this->assertEquals('http://business.example.com/', $data['data']['refs']['http://business.example.com/']['url']); - } - - public function testMf1Review() { - $url = 'http://source.example.com/hReview'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('review', $data['data']['type']); - $this->assertEquals('review', $data['data']['post-type']); - $this->assertEquals('Not great', $data['data']['name']); - $this->assertEquals('3', $data['data']['rating']); - $this->assertEquals('5', $data['data']['best']); - $this->assertEquals('This is the full text of the review', $data['data']['content']['text']); - $this->assertContains('http://product.example.com/', $data['data']['item']); - $this->assertArrayHasKey('http://product.example.com/', $data['data']['refs']); - $this->assertEquals('item', $data['data']['refs']['http://product.example.com/']['type']); - $this->assertEquals('The Reviewed Product', $data['data']['refs']['http://product.example.com/']['name']); - $this->assertEquals('http://product.example.com/', $data['data']['refs']['http://product.example.com/']['url']); - } - - public function testMf2Recipe() { - $url = 'http://source.example.com/h-recipe'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('recipe', $data['data']['type']); - $this->assertEquals('recipe', $data['data']['post-type']); - $this->assertEquals('Cookie Recipe', $data['data']['name']); - $this->assertEquals('12 Cookies', $data['data']['yield']); - $this->assertEquals('PT30M', $data['data']['duration']); - $this->assertEquals('The best chocolate chip cookie recipe', $data['data']['summary']); - $this->assertContains('3 cups flour', $data['data']['ingredient']); - $this->assertContains('chocolate chips', $data['data']['ingredient']); - } - - public function testEntryIsAnInvitee() { - $url = 'http://source.example.com/bridgy-invitee'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('https://www.facebook.com/555707837940351#tantek', $data['data']['url']); - $this->assertContains('https://www.facebook.com/tantek.celik', $data['data']['invitee']); - $this->assertArrayHasKey('https://www.facebook.com/tantek.celik', $data['data']['refs']); - $this->assertEquals('Tantek Çelik', $data['data']['refs']['https://www.facebook.com/tantek.celik']['name']); - } - - public function testEntryAtFragmentID() { - $url = 'http://source.example.com/fragment-id#comment-1000'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('note', $data['data']['post-type']); - $this->assertEquals('Comment text', $data['data']['content']['text']); - $this->assertEquals('http://source.example.com/fragment-id#comment-1000', $data['data']['url']); - $this->assertTrue($data['info']['found_fragment']); - } - - public function testEntryAtNonExistentFragmentID() { - $url = 'http://source.example.com/fragment-id#comment-404'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('http://source.example.com/fragment-id', $data['data']['url']); - $this->assertFalse($data['info']['found_fragment']); - } - - public function testCheckin() { - $url = 'http://source.example.com/checkin'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $venue = $data['data']['checkin']; - $this->assertEquals('checkin', $data['data']['post-type']); - $this->assertEquals('https://foursquare.com/v/57104d2e498ece022e169dca', $venue['url']); - $this->assertEquals('DreamHost', $venue['name']); - $this->assertEquals('45.518716', $venue['latitude']); - $this->assertEquals('Homebrew Website Club!', $data['data']['content']['text']); - $this->assertEquals('https://aaronparecki.com/2017/06/07/12/photo.jpg', $data['data']['photo'][0]); - $this->assertEquals('2017-06-07T17:14:40-07:00', $data['data']['published']); - $this->assertArrayNotHasKey('name', $data['data']); - } - - public function testCheckinURLOnly() { - $url = 'http://source.example.com/checkin-url'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('checkin', $data['data']['post-type']); - $venue = $data['data']['checkin']; - $this->assertEquals('https://foursquare.com/v/57104d2e498ece022e169dca', $venue['url']); - $this->assertEquals('Homebrew Website Club!', $data['data']['content']['text']); - $this->assertEquals('https://aaronparecki.com/2017/06/07/12/photo.jpg', $data['data']['photo'][0]); - $this->assertEquals('2017-06-07T17:14:40-07:00', $data['data']['published']); - $this->assertArrayNotHasKey('name', $data['data']); - } - - public function testXKCD() { - $url = 'http://xkcd.com/1810/'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals(200, $data['code']); - $this->assertEquals('xkcd', $data['source-format']); - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('photo', $data['data']['post-type']); - $this->assertEquals('http://xkcd.com/1810/', $data['data']['url']); - $this->assertEquals('Chat Systems', $data['data']['name']); - $this->assertContains('http://imgs.xkcd.com/comics/chat_systems_2x.png', $data['data']['photo']); - } - - public function testEntryHasMultipleURLs() { - $url = 'http://source.example.com/multiple-urls'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - // Should prioritize the URL on the same domain - $this->assertEquals($url, $data['data']['url']); - } - - public function testEntryHasMultipleURLsOffDomain() { - $url = 'http://source.example.com/multiple-urls-off-domain'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - // Neither URL is on the same domain, so should use the first - $this->assertEquals('http://one.example.com/test', $data['data']['url']); - } - - public function testInputIsJSON() { - $url = 'http://example.com/entry'; - - $mf2json = ['items' => [ - [ + ]] + ] + ]] + ] + ); + $xray = new \p3k\XRay(); + $parsed = $xray->process(false, $mf2JSON); + $this->assertEquals('mf2+json', $parsed['source-format']); + $item = $parsed['data']; + $this->assertEquals('entry', $item['type']); + $this->assertEquals('note', $item['post-type']); + $this->assertArrayNotHasKey('content', $item); + } + + public function testFindTargetLinkIsImage() + { + $url = 'http://source.example.com/link-is-img'; + $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com/photo.jpg']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertEquals('photo', $data->data->{'post-type'}); + $this->assertObjectNotHasAttribute('name', $data->data); + $this->assertEquals('This page has an img tag with the target URL.', $data->data->content->text); + } + + public function testFindTargetLinkIsVideo() + { + $url = 'http://source.example.com/link-is-video'; + $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com/movie.mp4']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertEquals('video', $data->data->{'post-type'}); + $this->assertObjectNotHasAttribute('name', $data->data); + $this->assertEquals('This page has a video tag with the target URL.', $data->data->content->text); + } + + public function testFindTargetLinkIsAudio() + { + $url = 'http://source.example.com/link-is-audio'; + $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com/media.mp3']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertEquals('audio', $data->data->{'post-type'}); + $this->assertObjectNotHasAttribute('name', $data->data); + $this->assertEquals('This page has an audio tag with the target URL.', $data->data->content->text); + } + + public function testFindTargetLinkInFeed() + { + $url = 'http://feed.example.com/jsonfeed'; + $response = $this->parse(['url' => $url, 'target' => 'http://www.manton.org/2017/11/5993.html']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + } + + public function testFindTargetLinkInHTMLInFeed() + { + $url = 'http://feed.example.com/jsonfeed'; + $response = $this->parse(['url' => $url, 'target' => 'http://www.manton.org/2016/11/todays-social-networks-are-broken.html']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + } + + public function testNotFindTargetLinkInHTMLInFeed() + { + $url = 'http://feed.example.com/jsonfeed'; + $response = $this->parse(['url' => $url, 'target' => 'http://example.com/']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectHasAttribute('error', $data); + $this->assertEquals('no_link_found', $data->error); + } + + public function testFindRelativeTargetLink() + { + $url = 'http://source.example.com/multiple-urls'; + $response = $this->parse(['url' => $url, 'target' => 'http://source.example.com/photo.jpg']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + } + + public function testTextContent() + { + $url = 'http://source.example.com/text-content'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertObjectNotHasAttribute('name', $data->data); + $this->assertEquals('This page has a link to target.example.com and some formatted text but is in a p-content element so is plaintext.', $data->data->content->text); + } + + public function testArticleWithFeaturedImage() + { + $url = 'http://source.example.com/article-with-featured-image'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertEquals('article', $data->data->{'post-type'}); + $this->assertEquals('Post Title', $data->data->name); + $this->assertEquals('This is a blog post.', $data->data->content->text); + $this->assertEquals('http://source.example.com/featured.jpg', $data->data->featured); + } + + public function testContentWithPrefixedName() + { + $url = 'http://source.example.com/content-with-prefixed-name'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertObjectNotHasAttribute('name', $data->data); + $this->assertEquals('note', $data->data->{'post-type'}); + $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->text); + $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->html); + } + + public function testContentWithDistinctName() + { + $url = 'http://source.example.com/content-with-distinct-name'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertEquals('Hello World', $data->data->name); + $this->assertEquals('article', $data->data->{'post-type'}); + $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->text); + $this->assertEquals('This page has a link to target.example.com and some formatted text.', $data->data->content->html); + } + + public function testNameWithNoContent() + { + $url = 'http://source.example.com/name-no-content'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertEquals('Hello World', $data->data->name); + $this->assertEquals('article', $data->data->{'post-type'}); + $this->assertObjectNotHasAttribute('content', $data->data); + } + + public function testEntryWithDuplicateCategories() + { + $url = 'http://source.example.com/h-entry-duplicate-categories'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertEquals(['indieweb'], $data->data->category); + } + + public function testEntryStripHashtagWithDuplicateCategories() + { + $url = 'http://source.example.com/h-entry-strip-hashtag-from-categories'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertContains('indieweb', $data->data->category); + $this->assertContains('xray', $data->data->category); + $this->assertEquals(2, count($data->data->category)); + } + + public function testNoHEntryMarkup() + { + $url = 'http://source.example.com/no-h-entry'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('unknown', $data->data->type); + $this->assertObjectNotHasAttribute('html', $data); + } + + public function testFindTargetInNoParsedResult() + { + $url = 'http://source.example.com/no-h-entry'; + $response = $this->parse(['url' => $url, 'target' => 'http://target.example.com']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertObjectNotHasAttribute('error', $data); + $this->assertEquals('unknown', $data->data->type); + } + + public function testReplyIsURL() + { + $url = 'http://source.example.com/reply-is-url'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('http://example.com/100', $data['data']['in-reply-to'][0]); + } + + public function testReplyIsHCite() + { + $url = 'http://source.example.com/reply-is-h-cite'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('reply', $data['data']['post-type']); + $this->assertEquals('http://example.com/100', $data['data']['in-reply-to'][0]); + $this->assertArrayHasKey('http://example.com/100', $data['data']['refs']); + $this->assertEquals('Example Post', $data['data']['refs']['http://example.com/100']['name']); + $this->assertEquals('http://example.com/100', $data['data']['refs']['http://example.com/100']['url']); + } + + public function testPersonTagIsURL() + { + $url = 'http://source.example.com/person-tag-is-url'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('http://alice.example.com/', $data['data']['category'][0]); + } + + public function testPersonTagIsHCard() + { + $url = 'http://source.example.com/person-tag-is-h-card'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('http://alice.example.com/', $data['data']['category'][0]); + $this->assertArrayHasKey('http://alice.example.com/', $data['data']['refs']); + $this->assertEquals('card', $data['data']['refs']['http://alice.example.com/']['type']); + $this->assertEquals('http://alice.example.com/', $data['data']['refs']['http://alice.example.com/']['url']); + $this->assertEquals('Alice', $data['data']['refs']['http://alice.example.com/']['name']); + } + + public function testSyndicationIsURL() + { + $url = 'http://source.example.com/has-syndication'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('http://syndicated.example/', $data['data']['syndication'][0]); + } + + public function testHEntryNoContent() + { + $url = 'http://source.example.com/h-entry-no-content'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertObjectNotHasAttribute('content', $data->data); + $this->assertEquals('This is a Post', $data->data->name); + } + + public function testHEntryIsNotFirstObject() + { + $url = 'http://source.example.com/h-entry-is-not-first'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + } + + public function testHEntryRSVP() + { + $url = 'http://source.example.com/h-entry-rsvp'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('rsvp', $data['data']['post-type']); + $this->assertEquals('I\'ll be there!', $data['data']['content']['text']); + $this->assertEquals('yes', $data['data']['rsvp']); + } + + public function testMultipleHEntryOnPermalink() + { + $url = 'http://source.example.com/multiple-h-entry-on-permalink'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('Primary Post', $data['data']['name']); + } + + public function testHEntryWithHCardBeforeIt() + { + $url = 'http://source.example.com/h-entry-with-h-card-before-it'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + } + + public function testHEntryWithHCardSibling() + { + $url = 'http://source.example.com/h-entry-with-h-card-sibling'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + } + + public function testHEntryWithTwoHCardsBeforeIt() + { + $url = 'http://source.example.com/h-entry-with-two-h-cards-before-it'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + } + + public function testHEntryRedirectWithHCardSibling() + { + $url = 'http://source.example.com/h-entry-redirect-with-h-card-sibling'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + } + + public function testSingleHEntryHasNoPermalink() + { + $url = 'http://source.example.com/single-h-entry-has-no-permalink'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + } + + public function testBridgyExampleWithNoMatchingURL() + { + $url = 'http://source.example.com/bridgy-example'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + } + + public function testEventWithHTMLDescription() + { + $url = 'http://source.example.com/h-event'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('event', $data['data']['type']); + $this->assertEquals('event', $data['data']['post-type']); + $this->assertEquals('Homebrew Website Club', $data['data']['name']); + $this->assertEquals($url, $data['data']['url']); + $this->assertEquals('2016-03-09T18:30', $data['data']['start']); + $this->assertEquals('2016-03-09T19:30', $data['data']['end']); + $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['content']['text']); + $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['content']['text']); + $this->assertStringStartsWith("

    Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...

    ", $data['data']['content']['html']); + $this->assertStringEndsWith('

    See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.

    ', $data['data']['content']['html']); + } + + public function testEventWithTextDescription() + { + $url = 'http://source.example.com/h-event-text-description'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('event', $data['data']['type']); + $this->assertEquals('event', $data['data']['post-type']); + $this->assertEquals('Homebrew Website Club', $data['data']['name']); + $this->assertEquals($url, $data['data']['url']); + $this->assertEquals('2016-03-09T18:30', $data['data']['start']); + $this->assertEquals('2016-03-09T19:30', $data['data']['end']); + $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['content']['text']); + $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['content']['text']); + $this->assertArrayNotHasKey('html', $data['data']['content']); + } + + public function testEventWithTextContent() + { + $url = 'http://source.example.com/h-event-text-content'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('event', $data['data']['type']); + $this->assertEquals('event', $data['data']['post-type']); + $this->assertEquals('Homebrew Website Club', $data['data']['name']); + $this->assertEquals($url, $data['data']['url']); + $this->assertEquals('2016-03-09T18:30', $data['data']['start']); + $this->assertEquals('2016-03-09T19:30', $data['data']['end']); + $this->assertStringStartsWith("Are you building your own website? Indie reader? Personal publishing web app? Or some other digital magic-cloud proxy? If so, come on by and join a gathering of people with likeminded interests. Bring your friends that want to start a personal web site. Exchange information, swap ideas, talk shop, help work on a project...", $data['data']['content']['text']); + $this->assertStringEndsWith("See the Homebrew Website Club Newsletter Volume 1 Issue 1 for a description of the first meeting.", $data['data']['content']['text']); + $this->assertArrayNotHasKey('html', $data['data']['content']); + $this->assertEquals('card', $data['data']['author']['type']); + $this->assertEquals('Event Author', $data['data']['author']['name']); + $this->assertEquals('http://source.example.com/', $data['data']['author']['url']); + } + + public function testEventWithHCardLocation() + { + $url = 'http://source.example.com/h-event-with-h-card-location'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('event', $data['data']['type']); + $this->assertEquals('event', $data['data']['post-type']); + $this->assertEquals('Homebrew Website Club', $data['data']['name']); + $this->assertEquals($url, $data['data']['url']); + $this->assertEquals('2016-02-09T18:30', $data['data']['start']); + $this->assertEquals('2016-02-09T19:30', $data['data']['end']); + $this->assertEquals('card', $data['data']['location']['type']); + $this->assertEquals('http://source.example.com/venue', $data['data']['location']['url']); + $this->assertEquals('Venue', $data['data']['location']['name']); + $this->assertEquals('45.5', $data['data']['location']['latitude']); + $this->assertEquals('-122.6', $data['data']['location']['longitude']); + $this->assertEquals('1234 Main St', $data['data']['location']['street-address']); + $this->assertEquals('Portland', $data['data']['location']['locality']); + $this->assertEquals('Oregon', $data['data']['location']['region']); + $this->assertEquals('USA', $data['data']['location']['country-name']); + } + + public function testEventWithFeaturedImage() + { + $url = 'http://source.example.com/h-event-featured'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('event', $data['data']['type']); + $this->assertEquals('http://source.example.com/featured.jpg', $data['data']['featured']); + } + + public function testMf2ReviewOfProduct() + { + $url = 'http://source.example.com/h-review-of-product'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('review', $data['data']['type']); + $this->assertEquals('review', $data['data']['post-type']); + $this->assertEquals('Review', $data['data']['name']); + $this->assertEquals('Not great', $data['data']['summary']); + $this->assertEquals('3', $data['data']['rating']); + $this->assertEquals('5', $data['data']['best']); + $this->assertEquals('This is the full text of the review', $data['data']['content']['text']); + $this->assertContains('red', $data['data']['category']); + $this->assertContains('blue', $data['data']['category']); + $this->assertContains('http://product.example.com/', $data['data']['item']); + $this->assertArrayHasKey('http://product.example.com/', $data['data']['refs']); + $this->assertEquals('product', $data['data']['refs']['http://product.example.com/']['type']); + $this->assertEquals('The Reviewed Product', $data['data']['refs']['http://product.example.com/']['name']); + $this->assertEquals('http://product.example.com/', $data['data']['refs']['http://product.example.com/']['url']); + } + + public function testMf2ReviewOfHCard() + { + $url = 'http://source.example.com/h-review-of-h-card'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('review', $data['data']['type']); + $this->assertEquals('review', $data['data']['post-type']); + $this->assertEquals('Review', $data['data']['name']); + $this->assertEquals('Not great', $data['data']['summary']); + $this->assertEquals('3', $data['data']['rating']); + $this->assertEquals('5', $data['data']['best']); + $this->assertEquals('This is the full text of the review', $data['data']['content']['text']); + $this->assertContains('http://business.example.com/', $data['data']['item']); + $this->assertArrayHasKey('http://business.example.com/', $data['data']['refs']); + $this->assertEquals('card', $data['data']['refs']['http://business.example.com/']['type']); + $this->assertEquals('The Reviewed Business', $data['data']['refs']['http://business.example.com/']['name']); + $this->assertEquals('http://business.example.com/', $data['data']['refs']['http://business.example.com/']['url']); + } + + public function testMf1Review() + { + $url = 'http://source.example.com/hReview'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('review', $data['data']['type']); + $this->assertEquals('review', $data['data']['post-type']); + $this->assertEquals('Not great', $data['data']['name']); + $this->assertEquals('3', $data['data']['rating']); + $this->assertEquals('5', $data['data']['best']); + $this->assertEquals('This is the full text of the review', $data['data']['content']['text']); + $this->assertContains('http://product.example.com/', $data['data']['item']); + $this->assertArrayHasKey('http://product.example.com/', $data['data']['refs']); + $this->assertEquals('item', $data['data']['refs']['http://product.example.com/']['type']); + $this->assertEquals('The Reviewed Product', $data['data']['refs']['http://product.example.com/']['name']); + $this->assertEquals('http://product.example.com/', $data['data']['refs']['http://product.example.com/']['url']); + } + + public function testMf2Recipe() + { + $url = 'http://source.example.com/h-recipe'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('recipe', $data['data']['type']); + $this->assertEquals('recipe', $data['data']['post-type']); + $this->assertEquals('Cookie Recipe', $data['data']['name']); + $this->assertEquals('12 Cookies', $data['data']['yield']); + $this->assertEquals('PT30M', $data['data']['duration']); + $this->assertEquals('The best chocolate chip cookie recipe', $data['data']['summary']); + $this->assertContains('3 cups flour', $data['data']['ingredient']); + $this->assertContains('chocolate chips', $data['data']['ingredient']); + } + + public function testEntryIsAnInvitee() + { + $url = 'http://source.example.com/bridgy-invitee'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('https://www.facebook.com/555707837940351#tantek', $data['data']['url']); + $this->assertContains('https://www.facebook.com/tantek.celik', $data['data']['invitee']); + $this->assertArrayHasKey('https://www.facebook.com/tantek.celik', $data['data']['refs']); + $this->assertEquals('Tantek Çelik', $data['data']['refs']['https://www.facebook.com/tantek.celik']['name']); + } + + public function testEntryAtFragmentID() + { + $url = 'http://source.example.com/fragment-id#comment-1000'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('note', $data['data']['post-type']); + $this->assertEquals('Comment text', $data['data']['content']['text']); + $this->assertEquals('http://source.example.com/fragment-id#comment-1000', $data['data']['url']); + $this->assertTrue($data['info']['found_fragment']); + } + + public function testEntryAtNonExistentFragmentID() + { + $url = 'http://source.example.com/fragment-id#comment-404'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('http://source.example.com/fragment-id', $data['data']['url']); + $this->assertFalse($data['info']['found_fragment']); + } + + public function testCheckin() + { + $url = 'http://source.example.com/checkin'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $venue = $data['data']['checkin']; + $this->assertEquals('checkin', $data['data']['post-type']); + $this->assertEquals('https://foursquare.com/v/57104d2e498ece022e169dca', $venue['url']); + $this->assertEquals('DreamHost', $venue['name']); + $this->assertEquals('45.518716', $venue['latitude']); + $this->assertEquals('Homebrew Website Club!', $data['data']['content']['text']); + $this->assertEquals('https://aaronparecki.com/2017/06/07/12/photo.jpg', $data['data']['photo'][0]); + $this->assertEquals('2017-06-07T17:14:40-07:00', $data['data']['published']); + $this->assertArrayNotHasKey('name', $data['data']); + } + + public function testCheckinURLOnly() + { + $url = 'http://source.example.com/checkin-url'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('checkin', $data['data']['post-type']); + $venue = $data['data']['checkin']; + $this->assertEquals('https://foursquare.com/v/57104d2e498ece022e169dca', $venue['url']); + $this->assertEquals('Homebrew Website Club!', $data['data']['content']['text']); + $this->assertEquals('https://aaronparecki.com/2017/06/07/12/photo.jpg', $data['data']['photo'][0]); + $this->assertEquals('2017-06-07T17:14:40-07:00', $data['data']['published']); + $this->assertArrayNotHasKey('name', $data['data']); + } + + public function testXKCD() + { + $url = 'http://xkcd.com/1810/'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals(200, $data['code']); + $this->assertEquals('xkcd', $data['source-format']); + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('photo', $data['data']['post-type']); + $this->assertEquals('http://xkcd.com/1810/', $data['data']['url']); + $this->assertEquals('Chat Systems', $data['data']['name']); + $this->assertContains('http://imgs.xkcd.com/comics/chat_systems_2x.png', $data['data']['photo']); + } + + public function testEntryHasMultipleURLs() + { + $url = 'http://source.example.com/multiple-urls'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + // Should prioritize the URL on the same domain + $this->assertEquals($url, $data['data']['url']); + } + + public function testEntryHasMultipleURLsOffDomain() + { + $url = 'http://source.example.com/multiple-urls-off-domain'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + // Neither URL is on the same domain, so should use the first + $this->assertEquals('http://one.example.com/test', $data['data']['url']); + } + + public function testInputIsJSON() + { + $url = 'http://example.com/entry'; + + $mf2json = ['items' => [ + [ 'type' => ['h-entry'], 'properties' => [ 'content' => [['html' => 'Hello World']] ] - ] - ]]; - - $response = $this->parse([ - 'body' => $mf2json, - 'url' => $url, - ]); - - $body = $response->getContent(); - $data = json_decode($body, true); - - $this->assertEquals('mf2+json', $data['source-format']); - $this->assertEquals('Hello World', $data['data']['content']['text']); - } - - public function testInputIsParsedMf2() { - $html = '

    Hello World

    '; - $mf2 = Mf2\parse($html, 'http://example.com/entry'); - - $url = 'http://example.com/entry'; - $response = $this->parse([ - 'url' => $url, - 'body' => json_encode($mf2) - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+json', $data['source-format']); - - $this->assertEquals('Hello World', $data['data']['content']['text']); - $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]); - } - - public function testInputIsParsedMf2WithHTML() { - $html = '

    Hello World

    '; - $mf2 = Mf2\parse($html, 'http://example.com/entry'); - - $url = 'http://example.com/entry'; - $response = $this->parse([ - 'url' => $url, - 'body' => json_encode($mf2) - ]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+json', $data['source-format']); - $this->assertEquals('Hello World', $data['data']['content']['text']); - $this->assertEquals('Hello World', $data['data']['content']['html']); - $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]); - } - - public function testHApp() { - $url = 'http://source.example.com/h-app'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertEquals('app', $data['data']['type']); - $this->assertEquals('http://source.example.com/images/quill.png', $data['data']['logo']); - $this->assertEquals('Quill', $data['data']['name']); - $this->assertEquals($url, $data['data']['url']); - $this->assertEquals(['http://source.example.com/redirect1','http://source.example.com/redirect2'], $data['data']['redirect-uri']); - $this->assertArrayNotHasKey('photo', $data['data']); - } - - public function testHXApp() { - $url = 'http://source.example.com/h-x-app'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body); - $this->assertEquals('mf2+html', $data->{'source-format'}); - $this->assertEquals('app', $data->data->type); - $this->assertEquals('http://source.example.com/images/quill.png', $data->data->logo); - $this->assertEquals('Quill', $data->data->name); - $this->assertEquals($url, $data->data->url); - $this->assertObjectNotHasAttribute('photo', $data->data); - } - - public function testDuplicateReplyURLValues() { - $url = 'http://source.example.com/duplicate-in-reply-to-urls'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('http://example.com/100', $data['data']['in-reply-to'][0]); - $this->assertEquals(1, count($data['data']['in-reply-to'])); - } - - public function testDuplicateLikeOfURLValues() { - $url = 'http://source.example.com/duplicate-like-of-urls'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('http://example.com/100', $data['data']['like-of'][0]); - $this->assertEquals(1, count($data['data']['like-of'])); - } - - public function testQuotationOf() { - $url = 'http://source.example.com/quotation-of'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('I’m so making this into a t-shirt', $data['data']['content']['text']); - $this->assertEquals('https://twitter.com/gitlost/status/1015005409726357504', $data['data']['quotation-of']); - $this->assertArrayHasKey('https://twitter.com/gitlost/status/1015005409726357504', $data['data']['refs']); - $q = $data['data']['refs']['https://twitter.com/gitlost/status/1015005409726357504']; - $this->assertEquals("Still can't git fer shit", $q['content']['text']); - $this->assertEquals('2018-07-05T22:52:02+00:00', $q['published']); - } - - public function testHTML5Markup() { - $url = 'http://source.example.com/html5-tags'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('Hello World', $data['data']['name']); - $this->assertEquals('The content of the blog post', $data['data']['content']['text']); - } - - public function testRelAlternateToMf2JSON() { - $url = 'http://source.example.com/rel-alternate-mf2-json'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+json', $data['source-format']); - $this->assertEquals('http://source.example.com/rel-alternate-mf2-json.json', $data['parsed-url']); - $this->assertEquals('Pretty great to see a new self-hosted IndieAuth server! Congrats @nilshauk, and great project name! https://twitter.com/nilshauk/status/1017485223716630528', $data['data']['content']['text']); - } - - public function testRelAlternateToNotFoundURL() { - $url = 'http://source.example.com/rel-alternate-not-found'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertArrayNotHasKey('parsed-url', $data); - $this->assertEquals('Test content with a rel alternate link to a 404 page', $data['data']['content']['text']); - } - - public function testRelAlternatePrioritizesJSON() { - $url = 'http://source.example.com/rel-alternate-priority'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+json', $data['source-format']); - $this->assertEquals('http://source.example.com/rel-alternate-priority.json', $data['parsed-url']); - $this->assertEquals('This should be the content from XRay', $data['data']['content']['text']); - } - - public function testRelAlternatePrioritizesMf2OverAS2() { - $url = 'http://source.example.com/rel-alternate-priority-mf2-as2'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+json', $data['source-format']); - $this->assertEquals('http://source.example.com/rel-alternate-priority.json', $data['parsed-url']); - $this->assertEquals('This should be the content from XRay', $data['data']['content']['text']); - } - - public function testRelAlternateFallsBackOnInvalidJSON() { - $url = 'http://source.example.com/rel-alternate-fallback'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+html', $data['source-format']); - $this->assertArrayNotHasKey('parsed-url', $data); - $this->assertEquals('XRay should use this content since the JSON in the rel-alternate is invalid', $data['data']['content']['text']); - } - - public function testMultipleContentTypeHeaders() { - $url = 'http://source.example.com/multiple-content-type'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('mf2+html', $data['source-format']); - } - - public function testFollowOf() { - $url = 'http://source.example.com/bridgy-follow'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('https://realize.be/', $data['data']['follow-of']); - $this->assertEquals('follow', $data['data']['post-type']); - } - - public function testFollowOfHCard() { - $url = 'http://source.example.com/follow-of-h-card'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('https://realize.be/', $data['data']['follow-of']); - $this->assertEquals('follow', $data['data']['post-type']); - } - - public function testRelCanonical() { - $url = 'http://source.example.com/rel-canonical'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('https://aaronparecki.com/2019/12/01/10/homeautomation', $data['data']['url']); - $this->assertEquals('https://aaronparecki.com/2019/12/01/10/homeautomation', $data['data']['rels']['canonical']); - } - - public function testTargetLinkOutsideHEntry() { - $url = 'http://source.example.com/target-test-link-outside-h-entry'; - $response = $this->parse(['url' => $url, 'target' => 'https://target.example.com/']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('no_link_found', $data['error']); - } - - public function testTargetLinkWithBadMf1() { - $url = 'http://source.example.com/target-test-only-bad-mf1'; - $response = $this->parse(['url' => $url, 'target' => 'https://target.example.com/']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('unknown', $data['data']['type']); - } - - public function testTargetLinkWithValidMf1() { - $url = 'http://source.example.com/target-test-only-good-mf1'; - $response = $this->parse(['url' => $url, 'target' => 'https://target.example.com/']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('entry', $data['data']['type']); - $this->assertEquals('target', $data['data']['content']['html']); - } - - public function testTargetLinkOutsideValidMf1() { - $url = 'http://source.example.com/target-test-link-outside-valid-mf1'; - $response = $this->parse(['url' => $url, 'target' => 'https://target.example.com/']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - // Since the link was found in the HTML, but not in the parsed tree, it shouldn't return the parsed document - $this->assertEquals('unknown', $data['data']['type']); - } - - public function testDisableMf1Parsing() { - $url = 'http://source.example.com/target-test-only-good-mf1'; - $response = $this->parse(['url' => $url, 'include-mf1' => 'false']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('unknown', $data['data']['type']); - } - - public function testEnableMf1Parsing() { - $url = 'http://source.example.com/target-test-only-good-mf1'; - $response = $this->parse(['url' => $url, 'include-mf1' => 'true']); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - - $this->assertEquals('entry', $data['data']['type']); - } + ] + ]]; + + $response = $this->parse( + [ + 'body' => $mf2json, + 'url' => $url, + ] + ); + + $body = $response->getContent(); + $data = json_decode($body, true); + + $this->assertEquals('mf2+json', $data['source-format']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + } + + public function testInputIsParsedMf2() + { + $html = '

    Hello World

    '; + $mf2 = Mf2\parse($html, 'http://example.com/entry'); + + $url = 'http://example.com/entry'; + $response = $this->parse( + [ + 'url' => $url, + 'body' => json_encode($mf2) + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+json', $data['source-format']); + + $this->assertEquals('Hello World', $data['data']['content']['text']); + $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]); + } + + public function testInputIsParsedMf2WithHTML() + { + $html = '

    Hello World

    '; + $mf2 = Mf2\parse($html, 'http://example.com/entry'); + + $url = 'http://example.com/entry'; + $response = $this->parse( + [ + 'url' => $url, + 'body' => json_encode($mf2) + ] + ); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+json', $data['source-format']); + $this->assertEquals('Hello World', $data['data']['content']['text']); + $this->assertEquals('Hello World', $data['data']['content']['html']); + $this->assertEquals('http://example.com/photo.jpg', $data['data']['photo'][0]); + } + + public function testHApp() + { + $url = 'http://source.example.com/h-app'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertEquals('app', $data['data']['type']); + $this->assertEquals('http://source.example.com/images/quill.png', $data['data']['logo']); + $this->assertEquals('Quill', $data['data']['name']); + $this->assertEquals($url, $data['data']['url']); + $this->assertEquals(['http://source.example.com/redirect1','http://source.example.com/redirect2'], $data['data']['redirect-uri']); + $this->assertArrayNotHasKey('photo', $data['data']); + } + + public function testHXApp() + { + $url = 'http://source.example.com/h-x-app'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body); + $this->assertEquals('mf2+html', $data->{'source-format'}); + $this->assertEquals('app', $data->data->type); + $this->assertEquals('http://source.example.com/images/quill.png', $data->data->logo); + $this->assertEquals('Quill', $data->data->name); + $this->assertEquals($url, $data->data->url); + $this->assertObjectNotHasAttribute('photo', $data->data); + } + + public function testDuplicateReplyURLValues() + { + $url = 'http://source.example.com/duplicate-in-reply-to-urls'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('http://example.com/100', $data['data']['in-reply-to'][0]); + $this->assertEquals(1, count($data['data']['in-reply-to'])); + } + + public function testDuplicateLikeOfURLValues() + { + $url = 'http://source.example.com/duplicate-like-of-urls'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('http://example.com/100', $data['data']['like-of'][0]); + $this->assertEquals(1, count($data['data']['like-of'])); + } + + public function testQuotationOf() + { + $url = 'http://source.example.com/quotation-of'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('I’m so making this into a t-shirt', $data['data']['content']['text']); + $this->assertEquals('https://twitter.com/gitlost/status/1015005409726357504', $data['data']['quotation-of']); + $this->assertArrayHasKey('https://twitter.com/gitlost/status/1015005409726357504', $data['data']['refs']); + $q = $data['data']['refs']['https://twitter.com/gitlost/status/1015005409726357504']; + $this->assertEquals("Still can't git fer shit", $q['content']['text']); + $this->assertEquals('2018-07-05T22:52:02+00:00', $q['published']); + } + + public function testHTML5Markup() + { + $url = 'http://source.example.com/html5-tags'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('Hello World', $data['data']['name']); + $this->assertEquals('The content of the blog post', $data['data']['content']['text']); + } + + public function testRelAlternateToMf2JSON() + { + $url = 'http://source.example.com/rel-alternate-mf2-json'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+json', $data['source-format']); + $this->assertEquals('http://source.example.com/rel-alternate-mf2-json.json', $data['parsed-url']); + $this->assertEquals('Pretty great to see a new self-hosted IndieAuth server! Congrats @nilshauk, and great project name! https://twitter.com/nilshauk/status/1017485223716630528', $data['data']['content']['text']); + } + + public function testRelAlternateToNotFoundURL() + { + $url = 'http://source.example.com/rel-alternate-not-found'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertArrayNotHasKey('parsed-url', $data); + $this->assertEquals('Test content with a rel alternate link to a 404 page', $data['data']['content']['text']); + } + + public function testRelAlternatePrioritizesJSON() + { + $url = 'http://source.example.com/rel-alternate-priority'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+json', $data['source-format']); + $this->assertEquals('http://source.example.com/rel-alternate-priority.json', $data['parsed-url']); + $this->assertEquals('This should be the content from XRay', $data['data']['content']['text']); + } + + public function testRelAlternatePrioritizesMf2OverAS2() + { + $url = 'http://source.example.com/rel-alternate-priority-mf2-as2'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+json', $data['source-format']); + $this->assertEquals('http://source.example.com/rel-alternate-priority.json', $data['parsed-url']); + $this->assertEquals('This should be the content from XRay', $data['data']['content']['text']); + } + + public function testRelAlternateFallsBackOnInvalidJSON() + { + $url = 'http://source.example.com/rel-alternate-fallback'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+html', $data['source-format']); + $this->assertArrayNotHasKey('parsed-url', $data); + $this->assertEquals('XRay should use this content since the JSON in the rel-alternate is invalid', $data['data']['content']['text']); + } + + public function testMultipleContentTypeHeaders() + { + $url = 'http://source.example.com/multiple-content-type'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('mf2+html', $data['source-format']); + } + + public function testFollowOf() + { + $url = 'http://source.example.com/bridgy-follow'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('https://realize.be/', $data['data']['follow-of']); + $this->assertEquals('follow', $data['data']['post-type']); + } + + public function testFollowOfHCard() + { + $url = 'http://source.example.com/follow-of-h-card'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('https://realize.be/', $data['data']['follow-of']); + $this->assertEquals('follow', $data['data']['post-type']); + } + + public function testRelCanonical() + { + $url = 'http://source.example.com/rel-canonical'; + $response = $this->parse(['url' => $url]); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('https://aaronparecki.com/2019/12/01/10/homeautomation', $data['data']['url']); + $this->assertEquals('https://aaronparecki.com/2019/12/01/10/homeautomation', $data['data']['rels']['canonical']); + } + + public function testTargetLinkOutsideHEntry() + { + $url = 'http://source.example.com/target-test-link-outside-h-entry'; + $response = $this->parse(['url' => $url, 'target' => 'https://target.example.com/']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('no_link_found', $data['error']); + } + + public function testTargetLinkWithBadMf1() + { + $url = 'http://source.example.com/target-test-only-bad-mf1'; + $response = $this->parse(['url' => $url, 'target' => 'https://target.example.com/']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('unknown', $data['data']['type']); + } + + public function testTargetLinkWithValidMf1() + { + $url = 'http://source.example.com/target-test-only-good-mf1'; + $response = $this->parse(['url' => $url, 'target' => 'https://target.example.com/']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('entry', $data['data']['type']); + $this->assertEquals('target', $data['data']['content']['html']); + } + + public function testTargetLinkOutsideValidMf1() + { + $url = 'http://source.example.com/target-test-link-outside-valid-mf1'; + $response = $this->parse(['url' => $url, 'target' => 'https://target.example.com/']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + // Since the link was found in the HTML, but not in the parsed tree, it shouldn't return the parsed document + $this->assertEquals('unknown', $data['data']['type']); + } + + public function testDisableMf1Parsing() + { + $url = 'http://source.example.com/target-test-only-good-mf1'; + $response = $this->parse(['url' => $url, 'include-mf1' => 'false']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('unknown', $data['data']['type']); + } + + public function testEnableMf1Parsing() + { + $url = 'http://source.example.com/target-test-only-good-mf1'; + $response = $this->parse(['url' => $url, 'include-mf1' => 'true']); + + $body = $response->getContent(); + $this->assertEquals(200, $response->getStatusCode()); + $data = json_decode($body, true); + + $this->assertEquals('entry', $data['data']['type']); + } } diff --git a/tests/SanitizeTest.php b/tests/SanitizeTest.php index ff86a5b..5bf84c1 100644 --- a/tests/SanitizeTest.php +++ b/tests/SanitizeTest.php @@ -2,193 +2,205 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -class SanitizeTest extends PHPUnit_Framework_TestCase { - - private $http; - - public function setUp() { - $this->client = new Parse(); - $this->client->http = new p3k\HTTP\Test(dirname(__FILE__).'/data/'); - $this->client->mc = null; - } - - private function parse($params) { - $request = new Request($params); - $response = new Response(); - return $this->client->parse($request, $response); - } - - public function testAllowsWhitelistedTags() { - $url = 'http://sanitize.example/entry-with-valid-tags'; - $response = $this->parse(['url' => $url]); - - $body = $response->getContent(); - $this->assertEquals(200, $response->getStatusCode()); - $data = json_decode($body, true); - $html = $data['data']['content']['html']; - - $this->assertEquals('entry', $data['data']['type']); - $this->assertContains('This content has only valid tags.', $html); - $this->assertContains('links,', $html, ' missing'); - $this->assertContains('abbreviations,', $html, ' missing'); - $this->assertContains('bold,', $html, ' missing'); - $this->assertContains('inline code,', $html, ' missing'); - $this->assertContains('delete,', $html, ' missing'); - $this->assertContains('emphasis,', $html, ' missing'); - $this->assertContains('italics,', $html, ' missing'); - $this->assertContains('images are allowed', $html, ' missing'); - $this->assertContains('inline quote,', $html, ' missing'); - $this->assertContains('strikethrough,', $html, ' missing'); - $this->assertContains('strong text,', $html, ' missing'); - $this->assertContains('', $html, '