Skip to content

Commit

Permalink
Got rid of Ocramius Package Version package as it has only PHP 7.4 su…
Browse files Browse the repository at this point in the history
…pport for Composer 2
  • Loading branch information
fulopattila122 committed Nov 4, 2020
1 parent 3b8cb7d commit 6fd2394
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 34 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/" },
Expand Down
32 changes: 32 additions & 0 deletions tests/DetectsEnumVersion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

/**
* Contains the DetectsEnumVersion trait.
*
* @copyright Copyright (c) 2020 Attila Fulop
* @author Attila Fulop
* @license MIT
* @since 2020-11-04
*
*/

namespace Konekt\Enum\Eloquent\Tests;

use Konekt\Enum\Enum;

trait DetectsEnumVersion
{
private function getEnumVersion(): string
{
return defined(Enum::class. '::__DEFAULT') ? '3.0.0' : '2.3.0';
}

private function getEnumVersionMajor(): int
{
$parts = explode('.', $this->getEnumVersion());

return (int) $parts[0];
}
}
18 changes: 2 additions & 16 deletions tests/EnumAccessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

class EnumAccessorTest extends TestCase
{
use DetectsEnumVersion;

/**
* @test
*/
Expand Down Expand Up @@ -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];
}
}
19 changes: 3 additions & 16 deletions tests/EnumToArrayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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];
}
}

0 comments on commit 6fd2394

Please sign in to comment.