From a2ea2fdfc46ca33a60380e17ff94d820b8dd8423 Mon Sep 17 00:00:00 2001 From: Jakub Srsen Date: Sat, 12 Oct 2019 21:53:11 +0100 Subject: [PATCH 1/2] Fixed string template syntax in CachedBuilderTest --- tests/Integration/CachedBuilderTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Integration/CachedBuilderTest.php b/tests/Integration/CachedBuilderTest.php index 4e9f7ca..2ebe7f5 100644 --- a/tests/Integration/CachedBuilderTest.php +++ b/tests/Integration/CachedBuilderTest.php @@ -49,7 +49,7 @@ public function testCreatingModelClearsCache() ]) ->get(sha1( "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_" . - '7_8_9_10-genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbooks' + "7_8_9_10-genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbooks" )); $this->assertNull($results); @@ -67,7 +67,7 @@ public function testUpdatingModelClearsCache() ]) ->get(sha1( "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_" . - '7_8_9_10-genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbooks' + "7_8_9_10-genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbooks" )); $this->assertNull($results); @@ -84,7 +84,7 @@ public function testDeletingModelClearsCache() ]) ->get(sha1( "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_" . - '7_8_9_10-genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbooks' + "7_8_9_10-genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbooks" )); $this->assertNull($results); From 6e900ad149fc646b57701607cc3610b0039b55af Mon Sep 17 00:00:00 2001 From: Jakub Srsen Date: Sat, 12 Oct 2019 23:34:53 +0100 Subject: [PATCH 2/2] Adapting pagination testing to allow for new Laravel versioning --- tests/Feature/PaginationTest.php | 42 ++++--------------- .../CachedBuilder/PaginateTest.php | 42 +++---------------- 2 files changed, 14 insertions(+), 70 deletions(-) diff --git a/tests/Feature/PaginationTest.php b/tests/Feature/PaginationTest.php index d5ed5bb..7c5dbbd 100644 --- a/tests/Feature/PaginationTest.php +++ b/tests/Feature/PaginationTest.php @@ -2,27 +2,19 @@ use GeneaLabs\LaravelModelCaching\Tests\FeatureTestCase; use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Book; -use Illuminate\Support\Str; class PaginationTest extends FeatureTestCase { public function testPaginationProvidesDifferentLinksOnDifferentPages() { - if (Str::startsWith(app()->version(), "5.6") - || Str::startsWith(app()->version(), "5.7") - || Str::startsWith(app()->version(), "5.8") - || Str::startsWith(app()->version(), "6.0") - ) { + // Checking the version start with 5.6, 5.7, 5.8 or 6. + if (preg_match("/^((5\.[6-8])|(6\.))/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; } - if (Str::startsWith(app()->version(), "5.5")) { - $page1ActiveLink = '
  • 1
  • '; - $page2ActiveLink = '
  • 2
  • '; - } - - if (Str::startsWith(app()->version(), "5.4")) { + // Checking the version 5.4 and 5.5 + if (preg_match("/^5\.[4-5]/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; } @@ -41,21 +33,12 @@ public function testPaginationProvidesDifferentLinksOnDifferentPages() public function testAdvancedPagination() { - if (Str::startsWith(app()->version(), "5.6") - || Str::startsWith(app()->version(), "5.7") - || Str::startsWith(app()->version(), "5.8") - || Str::startsWith(app()->version(), "6.0") - ) { + if (preg_match("/^((5\.[6-8])|(6\.))/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; } - if (Str::startsWith(app()->version(), "5.5")) { - $page1ActiveLink = '
  • 1
  • '; - $page2ActiveLink = '
  • 2
  • '; - } - - if (Str::startsWith(app()->version(), "5.4")) { + if (preg_match("/^5\.[4-5]/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; } @@ -67,21 +50,12 @@ public function testAdvancedPagination() public function testCustomPagination() { - if (Str::startsWith(app()->version(), "5.6") - || Str::startsWith(app()->version(), "5.7") - || Str::startsWith(app()->version(), "5.8") - || Str::startsWith(app()->version(), "6.0") - ) { + if (preg_match("/^((5\.[6-8])|(6\.))/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; } - if (Str::startsWith(app()->version(), "5.5")) { - $page1ActiveLink = '
  • 1
  • '; - $page2ActiveLink = '
  • 2
  • '; - } - - if (Str::startsWith(app()->version(), "5.4")) { + if (preg_match("/^5\.[4-5]/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; } diff --git a/tests/Integration/CachedBuilder/PaginateTest.php b/tests/Integration/CachedBuilder/PaginateTest.php index 7df45a4..e7872e4 100644 --- a/tests/Integration/CachedBuilder/PaginateTest.php +++ b/tests/Integration/CachedBuilder/PaginateTest.php @@ -36,23 +36,13 @@ public function testPaginationIsCached() public function testPaginationReturnsCorrectLinks() { - if (Str::startsWith(app()->version(), "5.6") - || Str::startsWith(app()->version(), "5.7") - || Str::startsWith(app()->version(), "5.8") - || Str::startsWith(app()->version(), "6.0") - ) { + if (preg_match("/^((5\.[6-8])|(6\.))/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; $page24ActiveLink = '
  • 24
  • '; } - if (Str::startsWith(app()->version(), "5.5")) { - $page1ActiveLink = '
  • 1
  • '; - $page2ActiveLink = '
  • 2
  • '; - $page24ActiveLink = '
  • 24
  • '; - } - - if (Str::startsWith(app()->version(), "5.4")) { + if (preg_match("/^5\.[4-5]/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; $page24ActiveLink = '
  • 24
  • '; @@ -75,23 +65,13 @@ public function testPaginationReturnsCorrectLinks() public function testPaginationWithOptionsReturnsCorrectLinks() { - if (Str::startsWith(app()->version(), "5.6") - || Str::startsWith(app()->version(), "5.7") - || Str::startsWith(app()->version(), "5.8") - || Str::startsWith(app()->version(), "6.0") - ) { + if (preg_match("/^((5\.[6-8])|(6\.))/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; $page24ActiveLink = '
  • 24
  • '; } - if (Str::startsWith(app()->version(), "5.5")) { - $page1ActiveLink = '
  • 1
  • '; - $page2ActiveLink = '
  • 2
  • '; - $page24ActiveLink = '
  • 24
  • '; - } - - if (Str::startsWith(app()->version(), "5.4")) { + if (preg_match("/^5\.[4-5]/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; $page24ActiveLink = '
  • 24
  • '; @@ -114,23 +94,13 @@ public function testPaginationWithOptionsReturnsCorrectLinks() public function testPaginationWithCustomOptionsReturnsCorrectLinks() { - if (Str::startsWith(app()->version(), "5.6") - || Str::startsWith(app()->version(), "5.7") - || Str::startsWith(app()->version(), "5.8") - || Str::startsWith(app()->version(), "6.0") - ) { + if (preg_match("/^((5\.[6-8])|(6\.))/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; $page24ActiveLink = '
  • 24
  • '; } - if (Str::startsWith(app()->version(), "5.5")) { - $page1ActiveLink = '
  • 1
  • '; - $page2ActiveLink = '
  • 2
  • '; - $page24ActiveLink = '
  • 24
  • '; - } - - if (Str::startsWith(app()->version(), "5.4")) { + if (preg_match("/^5\.[4-5]/", app()->version())) { $page1ActiveLink = '
  • 1
  • '; $page2ActiveLink = '
  • 2
  • '; $page24ActiveLink = '
  • 24
  • ';