Permalink
Browse files

Merge branch 'colonelpopcorn-facade-lumen-fix'

* colonelpopcorn-facade-lumen-fix:
  Refactor and test Lumen fix
  Fix version issue with Lumen.
  • Loading branch information...
mattstauffer committed Feb 10, 2018
2 parents a6b3354 + e65e5dd commit ae3a5bd533712d7982603ef592f3e311e90c44dc
Showing with 32 additions and 5 deletions.
  1. +8 −1 src/Facades/MailThief.php
  2. +3 −4 tests/TestCase.php
  3. +21 −0 tests/VersionDetectionTest.php
@@ -10,8 +10,15 @@ class MailThief extends Facade
{
protected static function getFacadeAccessor()
{
return (float) self::$app->version() >= 5.5
return self::normalizeAppVersion(self::$app->version()) >= 5.5
? MailThiefFiveFiveCompatible::class
: MailThiefFiveFourCompatible::class;
}
public static function normalizeAppVersion($version)
{
preg_match("/[0-9]*\.[0-9]*/", $version, $versions);
return (float) reset($versions);
}
}
@@ -4,8 +4,8 @@
use Illuminate\Contracts\View\Factory;
use MailThief\MailThiefFiveFourCompatible;
abstract class TestCase extends PHPUnit_Framework_TestCase {
abstract class TestCase extends PHPUnit_Framework_TestCase
{
protected function getViewFactory()
{
return tap(Mockery::mock(Factory::class), function ($factory) {
@@ -55,5 +55,4 @@ protected function getMailThief()
{
return new MailThiefFiveFourCompatible($this->getViewFactory(), $this->getConfigFactory());
}
}
}
@@ -0,0 +1,21 @@
<?php
use MailThief\Facades\MailThief;
class VersionDetectionTest extends TestCase
{
public function test_gets_laravel_versions()
{
$this->assertEquals(5.5, MailThief::normalizeAppVersion('5.5'));
$this->assertEquals(10.4, MailThief::normalizeAppVersion('10.4.1423'));
$this->assertEquals(6.12, MailThief::normalizeAppVersion('6.12.1'));
}
public function test_gets_lumen_versions()
{
$this->assertEquals(5.6, MailThief::normalizeAppVersion('Lumen (5.6.1) (Laravel Components 5.6.*)'));
$this->assertEquals(5.12, MailThief::normalizeAppVersion('Lumen (5.12.4) (Laravel Components 5.99.*)'));
$this->assertEquals(10.2, MailThief::normalizeAppVersion('Lumen 10.2.123'));
$this->assertEquals(4.20, MailThief::normalizeAppVersion('Version 4.20.1423 of the Esteemd Lumen Framework, Blessed Be It'));
}
}

0 comments on commit ae3a5bd

Please sign in to comment.