From 9733b0187297102239de15607e926401dcc858ec Mon Sep 17 00:00:00 2001 From: mauricius Date: Sat, 28 Jan 2017 17:07:42 +0100 Subject: [PATCH 1/2] Added Laravel 5.4 compatibility --- composer.json | 2 +- src/Kris/LaravelFormBuilder/Form.php | 2 +- src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php | 5 ++++- src/Kris/LaravelFormBuilder/FormHelper.php | 6 +++--- tests/FormBuilderTestCase.php | 4 ++-- tests/FormTest.php | 2 +- 6 files changed, 12 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 495b7ab0..feb4adbb 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ }, "require-dev": { "phpunit/phpunit": "~4.0", - "orchestra/testbench": "~3.0" + "orchestra/testbench-browser-kit": "~3.4" }, "extra": { "branch-alias": { diff --git a/src/Kris/LaravelFormBuilder/Form.php b/src/Kris/LaravelFormBuilder/Form.php index bd53be24..f3a5df9d 100644 --- a/src/Kris/LaravelFormBuilder/Form.php +++ b/src/Kris/LaravelFormBuilder/Form.php @@ -3,7 +3,7 @@ use Illuminate\Contracts\Events\Dispatcher as EventDispatcher; use Illuminate\Contracts\Validation\Factory as ValidatorFactory; use Illuminate\Contracts\Validation\Validator; -use Illuminate\Http\Exception\HttpResponseException; +use Illuminate\Http\Exceptions\HttpResponseException; use Illuminate\Http\Request; use Illuminate\Support\Arr; use Kris\LaravelFormBuilder\Events\AfterFieldCreation; diff --git a/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php b/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php index 5770ac2c..8a77c1fa 100644 --- a/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php +++ b/src/Kris/LaravelFormBuilder/FormBuilderServiceProvider.php @@ -89,7 +89,10 @@ private function registerFormIfHeeded() // LaravelCollective\HtmlBuilder 5.2 is not backward compatible and will throw an exception $version = substr(Application::VERSION, 0, 3); - if (str_is('5.0', $version) || str_is('5.1', $version)) { + if(str_is('5.4', $version)) { + $form = new LaravelForm($app[ 'html' ], $app[ 'url' ], $app[ 'view' ], $app[ 'session.store' ]->token()); + } + else if (str_is('5.0', $version) || str_is('5.1', $version)) { $form = new LaravelForm($app[ 'html' ], $app[ 'url' ], $app[ 'session.store' ]->getToken()); } else { diff --git a/src/Kris/LaravelFormBuilder/FormHelper.php b/src/Kris/LaravelFormBuilder/FormHelper.php index 264d720b..3598690a 100644 --- a/src/Kris/LaravelFormBuilder/FormHelper.php +++ b/src/Kris/LaravelFormBuilder/FormHelper.php @@ -7,7 +7,7 @@ use Illuminate\Support\Collection; use Kris\LaravelFormBuilder\Fields\FormField; use Kris\LaravelFormBuilder\Form; -use Symfony\Component\Translation\TranslatorInterface; +use Illuminate\Translation\Translator; class FormHelper { @@ -87,10 +87,10 @@ class FormHelper /** * @param View $view - * @param TranslatorInterface $translator + * @param Translator $translator * @param array $config */ - public function __construct(View $view, TranslatorInterface $translator, array $config = []) + public function __construct(View $view, Translator $translator, array $config = []) { $this->view = $view; $this->translator = $translator; diff --git a/tests/FormBuilderTestCase.php b/tests/FormBuilderTestCase.php index d992098f..1121234c 100644 --- a/tests/FormBuilderTestCase.php +++ b/tests/FormBuilderTestCase.php @@ -6,7 +6,7 @@ use Kris\LaravelFormBuilder\FormBuilder; use Kris\LaravelFormBuilder\FormHelper; use Kris\LaravelFormBuilder\Form; -use Orchestra\Testbench\TestCase; +use Orchestra\Testbench\BrowserKit\TestCase; use Illuminate\Database\Eloquent\Model; class TestModel extends Model { @@ -77,7 +77,7 @@ public function setUp() $this->view = $this->app['view']; $this->translator = $this->app['translator']; $this->request = $this->app['request']; - $this->request->setSession($this->app['session.store']); + $this->request->setLaravelSession($this->app['session.store']); $this->validatorFactory = $this->app['validator']; $this->eventDispatcher = $this->app['events']; $this->model = new TestModel(); diff --git a/tests/FormTest.php b/tests/FormTest.php index a44ee2dc..7214099d 100644 --- a/tests/FormTest.php +++ b/tests/FormTest.php @@ -1,6 +1,6 @@ Date: Tue, 31 Jan 2017 21:20:13 +0100 Subject: [PATCH 2/2] Restored testbench and added Session trait --- composer.json | 4 ++-- tests/Fields/CollectionTypeTest.php | 3 +++ tests/FormBuilderTestCase.php | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index feb4adbb..cc3b2b18 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,8 @@ "illuminate/validation": "5.*@dev" }, "require-dev": { - "phpunit/phpunit": "~4.0", - "orchestra/testbench-browser-kit": "~3.4" + "phpunit/phpunit": "~5.0", + "orchestra/testbench": "~3.4" }, "extra": { "branch-alias": { diff --git a/tests/Fields/CollectionTypeTest.php b/tests/Fields/CollectionTypeTest.php index c0f33d28..21e360cd 100644 --- a/tests/Fields/CollectionTypeTest.php +++ b/tests/Fields/CollectionTypeTest.php @@ -4,9 +4,12 @@ use Kris\LaravelFormBuilder\Fields\CollectionType; use Kris\LaravelFormBuilder\Fields\SelectType; use Kris\LaravelFormBuilder\Form; +use Illuminate\Foundation\Testing\Concerns\InteractsWithSession; class CollectionTypeTest extends FormBuilderTestCase { + use InteractsWithSession; + /** @test */ public function it_creates_collection() { diff --git a/tests/FormBuilderTestCase.php b/tests/FormBuilderTestCase.php index 1121234c..e4e52348 100644 --- a/tests/FormBuilderTestCase.php +++ b/tests/FormBuilderTestCase.php @@ -6,7 +6,7 @@ use Kris\LaravelFormBuilder\FormBuilder; use Kris\LaravelFormBuilder\FormHelper; use Kris\LaravelFormBuilder\Form; -use Orchestra\Testbench\BrowserKit\TestCase; +use Orchestra\Testbench\TestCase; use Illuminate\Database\Eloquent\Model; class TestModel extends Model {