Skip to content

Commit

Permalink
Updating the package for Laravel 5.5 (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc authored Sep 7, 2017
1 parent 674199a commit 7fb3bc4
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ checks:
tools:
external_code_coverage:
timeout: 600
runs: 3
runs: 2
php_code_sniffer:
enabled: true
config:
Expand Down
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ language: php
sudo: false

php:
- 5.6
- 7.0
- 7.1
- nightly
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/Models/AbstractModel.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace Arcanedev\LaravelSeo\Models;

use Arcanedev\LaravelSeo\Seo;
use Arcanedev\Support\Bases\Model;
use Arcanedev\Support\Database\Model;

/**
* Class AbstractModel
Expand Down
2 changes: 1 addition & 1 deletion tests/Models/MetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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,
Expand Down
4 changes: 2 additions & 2 deletions tests/Models/RedirectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/Models/SeoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
46 changes: 25 additions & 21 deletions tests/RedirectorManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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 */
Expand All @@ -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 */
Expand All @@ -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 */
Expand All @@ -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 */
Expand All @@ -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 */
Expand All @@ -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);
}

/* -----------------------------------------------------------------
Expand Down
23 changes: 1 addition & 22 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php namespace Arcanedev\LaravelSeo\Tests;

use Arcanedev\LaravelSeo\Seo;
use Orchestra\Testbench\BrowserKit\TestCase as BaseTestCase;
use Orchestra\Testbench\TestCase as BaseTestCase;

/**
* Class TestCase
Expand Down Expand Up @@ -93,27 +93,6 @@ private function setUpRoutes($router)
});
}

/* -----------------------------------------------------------------
| Custom Assert Methods
| -----------------------------------------------------------------
*/

/**
* Assert whether the client was redirected to a given URI.
*
* @param string $uri
* @param array $with
*
* @return self
*/
public function assertRedirectedTo($uri, $with = [])
{
self::assertInstanceOf(\Illuminate\Http\RedirectResponse::class, $this->response);
self::assertEquals($this->app['url']->to($uri), $this->response->headers->get('Location'));

return $this;
}

/* -----------------------------------------------------------------
| Other Methods
| -----------------------------------------------------------------
Expand Down

0 comments on commit 7fb3bc4

Please sign in to comment.