From 35d631f77a070ceac138125a93e3b1b6df66ea9c Mon Sep 17 00:00:00 2001 From: Pascal Baljet Date: Fri, 27 Nov 2020 15:56:07 +0100 Subject: [PATCH] Support for PHP 8.0 (#342) * WIP * parent d785a01f55ae1047b6c79c34f1b453b6762c80b0 author pascalbaljet 1606476758 +0100 committer pascalbaljet 1606478514 +0100 parent d785a01f55ae1047b6c79c34f1b453b6762c80b0 author pascalbaljet 1606476758 +0100 committer pascalbaljet 1606478501 +0100 Update composer.json Updated to Crawler v5 + Run test server on GA Fix styling Update composer.json Update composer.json Reversed PHP 7.4 support * Fix styling * Update composer.json * Update composer.json * Update composer.json Co-authored-by: pascalbaljet --- .github/workflows/run-tests.yml | 22 +++++++++---------- .php_cs.cache | 2 +- composer.json | 20 +++++++++-------- src/Crawler/Observer.php | 2 +- src/Crawler/Profile.php | 2 +- src/SitemapGenerator.php | 2 +- tests/CrawlProfileTest.php | 4 ++-- tests/CustomCrawlProfile.php | 2 +- ...ernate_can_be_added_to_the_sitemap__1.txt} | 6 ++--- ...ternate_can_be_added_to_the_sitemap__1.xml | 11 ---------- 10 files changed, 31 insertions(+), 42 deletions(-) rename tests/__snapshots__/{SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.php => SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.txt} (87%) delete mode 100644 tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.xml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b9ee332..e2b7af1 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -12,22 +12,13 @@ jobs: strategy: fail-fast: false matrix: - php: [7.4, 7.3] - laravel: [8.*, 7.*, 6.*, 5.8.*] + php: [8.0, 7.4] + laravel: [8.*] dependency-version: [prefer-lowest, prefer-stable] os: [ubuntu-latest] include: - laravel: 8.* testbench: 6.* - - laravel: 7.* - testbench: 5.* - - laravel: 6.* - testbench: 4.* - - laravel: 5.8.* - testbench: 3.8.* - exlude: - - laravel: 8.* - php: 7.2 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} @@ -35,6 +26,15 @@ jobs: - name: Checkout code uses: actions/checkout@v1 + - name: Install and start test server + run: | + cd tests/server + npm install + (node server.js &) || /bin/true + + - name: Wait for server bootup + run: sleep 5 + - name: Cache dependencies uses: actions/cache@v1 with: diff --git a/.php_cs.cache b/.php_cs.cache index 6ee1241..3b48cd0 100644 --- a/.php_cs.cache +++ b/.php_cs.cache @@ -1 +1 @@ -{"php":"7.4.10","version":"2.16.4","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sortAlgorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline_array":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true},"hashes":{"src\/SitemapServiceProvider.php":4046326413,"src\/Crawler\/Observer.php":3776578038,"src\/Crawler\/Profile.php":491304014,"src\/Sitemap.php":59941369,"src\/SitemapGenerator.php":551139945,"src\/SitemapIndex.php":2195872423,"src\/Tags\/Tag.php":655113915,"src\/Tags\/Url.php":3654747035,"src\/Tags\/Sitemap.php":291541337,"src\/Tags\/Alternate.php":2677822067,"tests\/UrlTest.php":3228679757,"tests\/CustomCrawlProfile.php":1103021984,"tests\/__snapshots__\/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.php":2144182188,"tests\/SitemapIndexTest.php":2799885370,"tests\/SitemapGeneratorTest.php":1773786182,"tests\/AlternateTest.php":1318703542,"tests\/CrawlProfileTest.php":1435152950,"tests\/SitemapTest.php":1907794861,"tests\/TestCase.php":2965666986}} \ No newline at end of file +{"php":"7.4.11","version":"2.16.7","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sortAlgorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline_array":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true},"hashes":{"src\/Crawler\/Profile.php":1529434799,"src\/Crawler\/Observer.php":2755382592,"src\/SitemapIndex.php":2195872423,"src\/SitemapGenerator.php":2380644183,"src\/SitemapServiceProvider.php":4046326413,"src\/Sitemap.php":59941369,"src\/Tags\/Alternate.php":2677822067,"src\/Tags\/Url.php":3654747035,"src\/Tags\/Tag.php":655113915,"src\/Tags\/Sitemap.php":291541337,"tests\/UrlTest.php":3228679757,"tests\/SitemapGeneratorTest.php":1773786182,"tests\/CustomCrawlProfile.php":3607391448,"tests\/AlternateTest.php":1318703542,"tests\/SitemapTest.php":1907794861,"tests\/SitemapIndexTest.php":2799885370,"tests\/__snapshots__\/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.php":2144182188,"tests\/CrawlProfileTest.php":641678678,"tests\/TestCase.php":2965666986}} \ No newline at end of file diff --git a/composer.json b/composer.json index 11590d5..8699b03 100644 --- a/composer.json +++ b/composer.json @@ -16,16 +16,18 @@ } ], "require": { - "php": "^7.2", - "illuminate/support": "~5.8.0|^6.0|^7.0|^8.0", - "nesbot/carbon": "^1.21|^2.0", - "spatie/crawler": "^4.1.0" + "php": "^7.4|^8.0", + "illuminate/support": "^8.0", + "guzzlehttp/guzzle": "^7.2", + "nesbot/carbon": "^2.0", + "spatie/crawler": "^5.0", + "symfony/dom-crawler": "^5.1.14" }, "require-dev": { - "mockery/mockery": "^1.3.1", - "orchestra/testbench": "~3.8.8|^4.0|^5.0|^6.0", - "phpunit/phpunit": "^8.3|^9.0|^9.3", - "spatie/phpunit-snapshot-assertions": "^3.0.0", + "mockery/mockery": "^1.3.3", + "orchestra/testbench": "^6.0", + "phpunit/phpunit": "^9.3", + "spatie/phpunit-snapshot-assertions": "^4.0", "spatie/temporary-directory": "^1.1" }, "autoload": { @@ -53,4 +55,4 @@ }, "minimum-stability": "dev", "prefer-stable": true -} +} \ No newline at end of file diff --git a/src/Crawler/Observer.php b/src/Crawler/Observer.php index 1d622c3..d4ad232 100644 --- a/src/Crawler/Observer.php +++ b/src/Crawler/Observer.php @@ -5,7 +5,7 @@ use GuzzleHttp\Exception\RequestException; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\UriInterface; -use Spatie\Crawler\CrawlObserver; +use Spatie\Crawler\CrawlObservers\CrawlObserver; class Observer extends CrawlObserver { diff --git a/src/Crawler/Profile.php b/src/Crawler/Profile.php index 2dfc3f8..79d7e61 100644 --- a/src/Crawler/Profile.php +++ b/src/Crawler/Profile.php @@ -3,7 +3,7 @@ namespace Spatie\Sitemap\Crawler; use Psr\Http\Message\UriInterface; -use Spatie\Crawler\CrawlProfile; +use Spatie\Crawler\CrawlProfiles\CrawlProfile; class Profile extends CrawlProfile { diff --git a/src/SitemapGenerator.php b/src/SitemapGenerator.php index dd42037..7b0d475 100644 --- a/src/SitemapGenerator.php +++ b/src/SitemapGenerator.php @@ -8,7 +8,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\UriInterface; use Spatie\Crawler\Crawler; -use Spatie\Crawler\CrawlProfile; +use Spatie\Crawler\CrawlProfiles\CrawlProfile; use Spatie\Sitemap\Crawler\Observer; use Spatie\Sitemap\Crawler\Profile; use Spatie\Sitemap\Tags\Url; diff --git a/tests/CrawlProfileTest.php b/tests/CrawlProfileTest.php index 056663e..734e2af 100644 --- a/tests/CrawlProfileTest.php +++ b/tests/CrawlProfileTest.php @@ -3,8 +3,8 @@ namespace Spatie\Sitemap\Test; use Spatie\Crawler\Crawler; -use Spatie\Crawler\CrawlInternalUrls; -use Spatie\Crawler\CrawlSubdomains; +use Spatie\Crawler\CrawlProfiles\CrawlInternalUrls; +use Spatie\Crawler\CrawlProfiles\CrawlSubdomains; use Spatie\Sitemap\Crawler\Profile; use Spatie\Sitemap\Sitemap; use Spatie\Sitemap\SitemapGenerator; diff --git a/tests/CustomCrawlProfile.php b/tests/CustomCrawlProfile.php index 990c7fe..ee7ab9a 100644 --- a/tests/CustomCrawlProfile.php +++ b/tests/CustomCrawlProfile.php @@ -3,7 +3,7 @@ namespace Spatie\Sitemap\Test; use Psr\Http\Message\UriInterface; -use Spatie\Crawler\CrawlProfile; +use Spatie\Crawler\CrawlProfiles\CrawlProfile; class CustomCrawlProfile extends CrawlProfile { diff --git a/tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.php b/tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.txt similarity index 87% rename from tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.php rename to tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.txt index 6c0624a..8c801bb 100644 --- a/tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.php +++ b/tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.txt @@ -1,6 +1,4 @@ - + http://localhost/home @@ -10,4 +8,4 @@ daily 0.8 -'; + \ No newline at end of file diff --git a/tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.xml b/tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.xml deleted file mode 100644 index e450cc9..0000000 --- a/tests/__snapshots__/SitemapTest__an_url_with_an_alternate_can_be_added_to_the_sitemap__1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - http://localhost/home - - - 2016-01-01T00:00:00+00:00 - daily - 0.8 - -