From 5b3d601b2cd840751a0413a44e14cc6c8f2b34f5 Mon Sep 17 00:00:00 2001 From: Harry Merritt Date: Mon, 7 Dec 2020 03:44:41 +0000 Subject: [PATCH 1/6] Encode search string to be URL compatible - changes spaces ' ' => '%20' --- src/Imdb.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Imdb.php b/src/Imdb.php index b182318..1032931 100644 --- a/src/Imdb.php +++ b/src/Imdb.php @@ -147,8 +147,12 @@ public function search(string $search, array $options = []): array // -> handles finding specific content from the dom $htmlPieces = new HtmlPieces; + // Encode search string as a standard URL string + // -> ' ' => '%20' + $searc_url = urlencode(urldecode($search)); + // Load imdb search page and parse the dom - $page = $dom->fetch("https://www.imdb.com/find?q=$search&s=".$options["category"], $options); + $page = $dom->fetch("https://www.imdb.com/find?q=$searc_url&s=".$options["category"], $options); // Add all search data to response $store $response->add("titles", $htmlPieces->get($page, "titles")); From d3218347c906c6d44cc146d98b18e412dde4b7b8 Mon Sep 17 00:00:00 2001 From: Harry Merritt Date: Mon, 7 Dec 2020 03:46:51 +0000 Subject: [PATCH 2/6] Add search test to cover URL encoding --- tests/ImdbTest.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/ImdbTest.php b/tests/ImdbTest.php index 1f850cd..c061cf6 100644 --- a/tests/ImdbTest.php +++ b/tests/ImdbTest.php @@ -72,6 +72,11 @@ public function testSearch() $this->assertEquals('Interstellar', $search['titles'][0]['title']); $this->assertEquals('tt0816692', $search['titles'][0]['id']); + + $search_2 = $imdb->search('The Life and Death of Colonel Blimp'); + + $this->assertEquals('The Life and Death of Colonel Blimp', $search_2['titles'][0]['title']); + $this->assertEquals('tt0036112', $search_2['titles'][0]['id']); } public function test404Page() From fe5a4d19f6f5514fbcb29fdaeb98d72b20fe8251 Mon Sep 17 00:00:00 2001 From: Harry Merritt Date: Mon, 7 Dec 2020 03:53:05 +0000 Subject: [PATCH 3/6] Fix typo in search_url variable name - searc_url => search_url --- src/Imdb.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Imdb.php b/src/Imdb.php index 1032931..0ee8bad 100644 --- a/src/Imdb.php +++ b/src/Imdb.php @@ -149,10 +149,10 @@ public function search(string $search, array $options = []): array // Encode search string as a standard URL string // -> ' ' => '%20' - $searc_url = urlencode(urldecode($search)); + $search_url = urlencode(urldecode($search)); // Load imdb search page and parse the dom - $page = $dom->fetch("https://www.imdb.com/find?q=$searc_url&s=".$options["category"], $options); + $page = $dom->fetch("https://www.imdb.com/find?q=$search_url&s=".$options["category"], $options); // Add all search data to response $store $response->add("titles", $htmlPieces->get($page, "titles")); From 7f29219f9e6220ffff04ac52a758593df9b1360a Mon Sep 17 00:00:00 2001 From: Harry Merritt Date: Mon, 7 Dec 2020 04:03:00 +0000 Subject: [PATCH 4/6] Do not convert warnings to exceptions in phpunit.xml --- phpunit.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index d0aa7db..e63f6ce 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -4,8 +4,8 @@ bootstrap="phpunit.php" colors="true" convertErrorsToExceptions="true" - convertNoticesToExceptions="true" - convertWarningsToExceptions="true" + convertNoticesToExceptions="false" + convertWarningsToExceptions="false" processIsolation="false" stopOnFailure="false" > From c7130bed82f261cccdbe0314366510d80404fe09 Mon Sep 17 00:00:00 2001 From: Harry Merritt Date: Mon, 7 Dec 2020 04:19:50 +0000 Subject: [PATCH 5/6] Update .travis.yml to use a specific version of composer --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c0cf589..b4a6f57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,12 +4,12 @@ php: - 7.3 install: - - composer self-update - - composer install --dev --no-interaction + - composer self-update 1.9.3 + - composer install --no-interaction script: - mkdir -p build/logs - php vendor/bin/phpunit --coverage-clover build/logs/clover.xml after_script: - - travis_retry php vendor/bin/php-coveralls -v \ No newline at end of file + - travis_retry php vendor/bin/php-coveralls -v From a94f483aa66f75227d3ae4e2eaedbadba8714ae0 Mon Sep 17 00:00:00 2001 From: Harry Merritt Date: Mon, 7 Dec 2020 04:33:11 +0000 Subject: [PATCH 6/6] Update .travis.yml to run tests but not coverage - coverage has been failing for an unknown reason --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b4a6f57..ed4d4c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ install: script: - mkdir -p build/logs - - php vendor/bin/phpunit --coverage-clover build/logs/clover.xml + - composer test after_script: - travis_retry php vendor/bin/php-coveralls -v