From 7fb3bc4bd4d09bfc6c07d19993386e2227947f6f Mon Sep 17 00:00:00 2001 From: ARCANEDEV Date: Thu, 7 Sep 2017 18:00:31 +0100 Subject: [PATCH] Updating the package for Laravel 5.5 (#10) --- .scrutinizer.yml | 2 +- .travis.yml | 1 - composer.json | 12 ++++----- src/Models/AbstractModel.php | 2 +- tests/Models/MetaTest.php | 2 +- tests/Models/RedirectTest.php | 4 +-- tests/Models/SeoTest.php | 2 +- tests/RedirectorManagerTest.php | 46 ++++++++++++++++++--------------- tests/TestCase.php | 23 +---------------- 9 files changed, 38 insertions(+), 56 deletions(-) diff --git a/.scrutinizer.yml b/.scrutinizer.yml index 512a47a..2880858 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -23,7 +23,7 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 3 + runs: 2 php_code_sniffer: enabled: true config: diff --git a/.travis.yml b/.travis.yml index a4500e0..f16602e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ language: php sudo: false php: - - 5.6 - 7.0 - 7.1 - nightly diff --git a/composer.json b/composer.json index bf23fe8..9e7f119 100644 --- a/composer.json +++ b/composer.json @@ -14,14 +14,14 @@ "type": "library", "license": "MIT", "require": { - "php": ">=5.6", - "arcanedev/support": "~4.1.0" + "php": ">=7.0", + "arcanedev/support": "~4.2.0" }, "require-dev": { - "phpunit/phpcov": "~3.0", - "phpunit/phpunit": "~5.0", - "orchestra/database": "~3.4.0", - "orchestra/testbench-browser-kit": "~3.4.0" + "phpunit/phpcov": "~4.0", + "phpunit/phpunit": "~6.0", + "orchestra/database": "~3.5.0", + "orchestra/testbench": "~3.5.0" }, "autoload": { "psr-4": { diff --git a/src/Models/AbstractModel.php b/src/Models/AbstractModel.php index 8ee156e..a4f91fe 100644 --- a/src/Models/AbstractModel.php +++ b/src/Models/AbstractModel.php @@ -1,7 +1,7 @@ seo; - $this->seeInDatabase('seo_metas', [ + $this->assertDatabaseHas('seo_metas', [ 'id' => $seo->id, 'seoable_id' => 1, 'seoable_type' => Post::class, diff --git a/tests/Models/RedirectTest.php b/tests/Models/RedirectTest.php index e04c7e4..c68f2cc 100644 --- a/tests/Models/RedirectTest.php +++ b/tests/Models/RedirectTest.php @@ -25,7 +25,7 @@ public function it_can_create_and_delete() $new = '/new-url' ); - $this->seeInDatabase('seo_redirects', [ + $this->assertDatabaseHas('seo_redirects', [ 'old_url' => $old, 'new_url' => $new, 'status' => Response::HTTP_MOVED_PERMANENTLY, @@ -36,7 +36,7 @@ public function it_can_create_and_delete() $redirect->delete(); - $this->notSeeInDatabase('seo_redirects', [ + $this->assertDatabaseMissing('seo_redirects', [ 'old_url' => $old, 'new_url' => $new, 'status' => Response::HTTP_MOVED_PERMANENTLY, diff --git a/tests/Models/SeoTest.php b/tests/Models/SeoTest.php index 85cf07e..0756f16 100644 --- a/tests/Models/SeoTest.php +++ b/tests/Models/SeoTest.php @@ -51,7 +51,7 @@ public function it_can_create() $seo = $post->seo; - $this->seeInDatabase('seo_metas', [ + $this->assertDatabaseHas('seo_metas', [ 'id' => $seo->id, 'seoable_id' => 1, 'seoable_type' => Post::class, diff --git a/tests/RedirectorManagerTest.php b/tests/RedirectorManagerTest.php index 5970742..02c8873 100644 --- a/tests/RedirectorManagerTest.php +++ b/tests/RedirectorManagerTest.php @@ -117,8 +117,8 @@ public function it_can_build_eloquent_driver() /** @test */ public function it_will_not_interfere_with_existing_pages() { - $this->visit('existing-page') - ->see('existing page'); + $this->get('existing-page') + ->assertSeeText('existing page'); } /** @test */ @@ -128,11 +128,10 @@ public function it_will_redirect_a_non_existing_page_with_a_permanent_redirect() 'non-existing-page' => 'existing-page', ]); - $this->get('non-existing-page'); + $response = $this->get('non-existing-page'); - $this->assertRedirectedTo('existing-page'); - - $this->assertResponseStatus(Response::HTTP_MOVED_PERMANENTLY); + $response->assertStatus(Response::HTTP_MOVED_PERMANENTLY); + $response->assertRedirect('existing-page'); } /** @test */ @@ -142,9 +141,9 @@ public function it_will_not_redirect_an_url_that_it_not_configured() 'non-existing-page' => '/existing-page', ]); - $this->get('/not-configured'); + $response = $this->get('/not-configured'); - $this->assertResponseStatus(Response::HTTP_NOT_FOUND); + $response->assertStatus(Response::HTTP_NOT_FOUND); } /** @test */ @@ -154,9 +153,10 @@ public function it_can_use_named_parameters() 'segment1/{id}/segment2/{slug}' => 'segment2/{slug}', ]); - $this->get('segment1/123/segment2/abc'); + $response = $this->get('segment1/123/segment2/abc'); - $this->assertRedirectedTo('segment2/abc'); + $response->assertStatus(Response::HTTP_MOVED_PERMANENTLY); + $response->assertRedirect('segment2/abc'); } /** @test */ @@ -166,9 +166,10 @@ public function it_can_use_multiple_named_parameters_in_one_segment() 'new-segment/{id}-{slug}' => 'new-segment/{id}', ]); - $this->get('new-segment/123-blablabla'); + $response = $this->get('new-segment/123-blablabla'); - $this->assertRedirectedTo('new-segment/123'); + $response->assertStatus(Response::HTTP_MOVED_PERMANENTLY); + $response->assertRedirect('new-segment/123'); } /** @test */ @@ -178,10 +179,10 @@ public function it_can_optionally_set_the_redirect_status_code() 'temporarily-moved' => ['just-for-now', Response::HTTP_FOUND], ]); - $this->get('temporarily-moved'); + $response = $this->get('temporarily-moved'); - $this->assertRedirectedTo('just-for-now'); - $this->assertResponseStatus(Response::HTTP_FOUND); + $response->assertRedirect('just-for-now'); + $response->assertStatus(Response::HTTP_FOUND); } /** @test */ @@ -191,25 +192,28 @@ public function it_can_use_optional_parameters() 'old-segment/{parameter1?}/{parameter2?}' => 'new-segment', ]); - $this->get('old-segment'); + $response = $this->get('old-segment'); - $this->assertRedirectedTo('new-segment'); + $response->assertStatus(Response::HTTP_MOVED_PERMANENTLY); + $response->assertRedirect('new-segment'); $this->get('old-segment/old-segment2'); - $this->assertRedirectedTo('new-segment'); + $response->assertStatus(Response::HTTP_MOVED_PERMANENTLY); + $response->assertRedirect('new-segment'); $this->get('old-segment/old-segment2/old-segment3'); - $this->assertRedirectedTo('new-segment'); + $response->assertStatus(Response::HTTP_MOVED_PERMANENTLY); + $response->assertRedirect('new-segment'); } /** @test */ public function it_will_not_redirect_requests_that_are_not_404s() { - $this->get('response-code/500'); + $response = $this->get('response-code/500'); - $this->assertResponseStatus(500); + $response->assertStatus(Response::HTTP_INTERNAL_SERVER_ERROR); } /* ----------------------------------------------------------------- diff --git a/tests/TestCase.php b/tests/TestCase.php index 8bb0494..c57f38c 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,7 +1,7 @@ response); - self::assertEquals($this->app['url']->to($uri), $this->response->headers->get('Location')); - - return $this; - } - /* ----------------------------------------------------------------- | Other Methods | -----------------------------------------------------------------