From 3df34c76a191eb8d89718131ab503a697a5cb068 Mon Sep 17 00:00:00 2001 From: Ali Shaikh Date: Fri, 8 Jan 2021 20:04:26 +0500 Subject: [PATCH 1/3] Added support for PHP 8 * Dropped support for versions below PHP v7.4 * Upgraded PHPUnit to v9 * Updated tests to support PHPUnit v9 --- composer.json | 4 +-- phpunit.xml | 26 ++++++++----------- tests/ReadTimeTest.php | 58 +++++++++++++++++++++--------------------- 3 files changed, 41 insertions(+), 47 deletions(-) diff --git a/composer.json b/composer.json index 817787d..adc0581 100644 --- a/composer.json +++ b/composer.json @@ -29,10 +29,10 @@ ] }, "require": { - "php": "~7.0" + "php": "^7.4|^8.0" }, "require-dev": { - "phpunit/phpunit": "^6.4" + "phpunit/phpunit": "^9.3" }, "autoload-dev": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index 7a16ca3..a691e01 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,22 +1,16 @@ - + + + + src/ + + tests - - - src/ - - - \ No newline at end of file + diff --git a/tests/ReadTimeTest.php b/tests/ReadTimeTest.php index 23e5043..c7fd605 100644 --- a/tests/ReadTimeTest.php +++ b/tests/ReadTimeTest.php @@ -13,9 +13,9 @@ class ReadTimeTest extends TestCase /** @test string */ protected $sidebarContent; - protected function setUp() + protected function setUp(): void { - $this->mainContent = <<mainContent = <<Chicken Enchiladas By Leroy Jenkins

@@ -42,7 +42,7 @@ protected function setUp() HTML; - $this->sidebarContent = <<sidebarContent = <<

  • @@ -75,99 +75,99 @@ protected function setUp() /** @test */ public function can_output_read_time() { - $result = (new ReadTime($this->mainContent))->get(); + $result = (new ReadTime($this->mainContent))->get(); $this->assertSame($result, '1 minute read'); } /** @test */ public function can_accept_array_of_content() { - $result = (new ReadTime([$this->mainContent, $this->sidebarContent]))->get(); + $result = (new ReadTime([$this->mainContent, $this->sidebarContent]))->get(); $this->assertSame($result, '1 minute read'); } /** @test */ public function can_change_wpm() { - $result = (new ReadTime($this->mainContent))->wpm(150)->toArray(); + $result = (new ReadTime($this->mainContent))->wpm(150)->toArray(); $this->assertSame($result['words_per_minute'], 150); } /** @test */ public function can_set_time_only() { - $result = (new ReadTime($this->mainContent))->timeOnly(true)->toArray(); + $result = (new ReadTime($this->mainContent))->timeOnly(true)->toArray(); $this->assertTrue($result['time_only']); } /** @test */ public function can_allow_seconds() { - $result = (new ReadTime($this->mainContent))->omitSeconds(false)->toArray(); + $result = (new ReadTime($this->mainContent))->omitSeconds(false)->toArray(); $this->assertFalse($result['omit_seconds']); } /** @test */ public function can_change_translation() { - $spanish = [ - 'min' => 'min', - 'minute' => 'minuto', - 'sec' => 'seg', - 'second' => 'segundo', - 'read' => 'leer' - ]; - $result = (new ReadTime($this->mainContent))->setTranslation($spanish)->getTranslation('read'); + $spanish = [ + 'min' => 'min', + 'minute' => 'minuto', + 'sec' => 'seg', + 'second' => 'segundo', + 'read' => 'leer' + ]; + $result = (new ReadTime($this->mainContent))->setTranslation($spanish)->getTranslation('read'); $this->assertSame($result, 'leer'); } /** @test */ public function can_get_translation_array() { - $result = (new ReadTime($this->mainContent))->getTranslation(); - $this->assertInternalType('array', $result); + $result = (new ReadTime($this->mainContent))->getTranslation(); + $this->assertIsArray($result); } /** @test */ public function can_get_translation_key() { - $result = (new ReadTime($this->mainContent))->getTranslation('minute'); - $this->assertSame($result, 'minute'); + $result = (new ReadTime($this->mainContent))->getTranslation('minute'); + $this->assertSame($result, 'minute'); } /** @test */ public function can_read_right_to_left() { - $result = (new ReadTime($this->mainContent))->omitSeconds(false)->rtl()->get(); + $result = (new ReadTime($this->mainContent))->omitSeconds(false)->rtl()->get(); $this->assertSame($result, 'read second 10 minute 1'); } /** @test */ public function can_output_array() { - $result = (new ReadTime($this->mainContent))->toArray(); - $this->assertInternalType('array', $result); + $result = (new ReadTime($this->mainContent))->toArray(); + $this->assertIsArray($result); } /** @test */ public function can_output_json() { - $result = (new ReadTime($this->mainContent))->toJson(); - $this->assertInternalType('string', $result); + $result = (new ReadTime($this->mainContent))->toJson(); + $this->assertJson($result); } /** @test */ public function can_invoke_class_for_read_time() { - $result = new ReadTime($this->mainContent); - $this->assertInternalType('string', $result()); + $result = new ReadTime($this->mainContent); + $this->assertIsString($result()); } /** @test */ public function can_cast_as_string_for_read_time() { - $result = new ReadTime($this->mainContent); - $this->assertInternalType('string', (string) $result); + $result = new ReadTime($this->mainContent); + $this->assertIsString((string)$result); } /** @test */ From 7348af5a9e589b013bf1ff1f023ddee58817dc0f Mon Sep 17 00:00:00 2001 From: Ali Shaikh Date: Fri, 8 Jan 2021 20:11:51 +0500 Subject: [PATCH 2/3] Updated README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2925ecb..f2a52cb 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,14 @@ A PHP package to show users how long it takes to read content. Install via composer: +For PHP version 7.4+ ``` -composer require mtownsend/read-time +composer require mtownsend/read-time "^2" +``` + +For PHP version less than 7.4 +``` +composer require mtownsend/read-time "^1.1" ``` *This package is designed to work with any PHP 7.0+ application but has special support for Laravel.* From f19d6510a14445204a0b40b998787f891a84adb2 Mon Sep 17 00:00:00 2001 From: Mark Townsend Date: Mon, 11 Jan 2021 07:46:39 -0600 Subject: [PATCH 3/3] Removed version install comments --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f2a52cb..de48d27 100644 --- a/README.md +++ b/README.md @@ -8,16 +8,12 @@ A PHP package to show users how long it takes to read content. Install via composer: -For PHP version 7.4+ -``` -composer require mtownsend/read-time "^2" -``` -For PHP version less than 7.4 ``` -composer require mtownsend/read-time "^1.1" +composer require mtownsend/read-time ``` + *This package is designed to work with any PHP 7.0+ application but has special support for Laravel.* ### Registering the service provider (Laravel)