From 6fd239499253d2265cc357b97fa23c2ce7d4083a Mon Sep 17 00:00:00 2001 From: Attila Fulop Date: Wed, 4 Nov 2020 09:15:14 +0100 Subject: [PATCH] Got rid of Ocramius Package Version package as it has only PHP 7.4 support for Composer 2 --- composer.json | 3 +-- tests/DetectsEnumVersion.php | 32 ++++++++++++++++++++++++++++++++ tests/EnumAccessorTest.php | 18 ++---------------- tests/EnumToArrayTest.php | 19 +++---------------- 4 files changed, 38 insertions(+), 34 deletions(-) create mode 100644 tests/DetectsEnumVersion.php diff --git a/composer.json b/composer.json index 5ed0cf1..e7e2fcd 100644 --- a/composer.json +++ b/composer.json @@ -28,8 +28,7 @@ }, "require-dev": { "phpunit/phpunit": "6.3 - 7.5|~8.0", - "illuminate/events": "5.*|6.*|7.*|8.*", - "ocramius/package-versions": "^1.2|^2.0" + "illuminate/events": "5.*|6.*|7.*|8.*" }, "autoload": { "psr-4": { "Konekt\\Enum\\Eloquent\\": "src/" }, diff --git a/tests/DetectsEnumVersion.php b/tests/DetectsEnumVersion.php new file mode 100644 index 0000000..76c748e --- /dev/null +++ b/tests/DetectsEnumVersion.php @@ -0,0 +1,32 @@ +getEnumVersion()); + + return (int) $parts[0]; + } +} diff --git a/tests/EnumAccessorTest.php b/tests/EnumAccessorTest.php index c481aab..e6f4964 100644 --- a/tests/EnumAccessorTest.php +++ b/tests/EnumAccessorTest.php @@ -21,6 +21,8 @@ class EnumAccessorTest extends TestCase { + use DetectsEnumVersion; + /** * @test */ @@ -135,20 +137,4 @@ public function it_doesnt_break_related_properties() $this->assertInstanceOf(Client::class, $order->client); $this->assertEquals($client->id, $order->client->id); } - - private function getEnumVersion() - { - $raw_version = \PackageVersions\Versions::getVersion('konekt/enum'); - - $parts = explode('@', $raw_version); - - return $parts[0]; - } - - private function getEnumVersionMajor() - { - $parts = explode('.', $this->getEnumVersion()); - - return $parts[0]; - } } diff --git a/tests/EnumToArrayTest.php b/tests/EnumToArrayTest.php index 6af0f55..c5fd02e 100644 --- a/tests/EnumToArrayTest.php +++ b/tests/EnumToArrayTest.php @@ -15,9 +15,12 @@ use Konekt\Enum\Eloquent\Tests\Models\OrderStatusV2; use Konekt\Enum\Eloquent\Tests\Models\OrderV2; use Konekt\Enum\Eloquent\Tests\Models\OrderStatus; +use Konekt\Enum\Enum; class EnumToArrayTest extends TestCase { + use DetectsEnumVersion; + /** * @test */ @@ -124,20 +127,4 @@ public function returns_enum_v2_default_string_value_when_attribute_is_null() $this->assertIsString($array['status']); $this->assertEquals($array['status'], OrderStatusV2::__default); } - - private function getEnumVersion() - { - $raw_version = \PackageVersions\Versions::getVersion('konekt/enum'); - - $parts = explode('@', $raw_version); - - return $parts[0]; - } - - private function getEnumVersionMajor() - { - $parts = explode('.', $this->getEnumVersion()); - - return $parts[0]; - } }