From a1475203a1bfc5b248f80d317ebb5bb0fb6d36f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=2E=20Nagy=20Gerg=C5=91?= Date: Thu, 25 Jan 2024 13:24:33 +0100 Subject: [PATCH] console tests --- tests/Console/ActionMakeTest.php | 24 ++++++++++++++++++++++++ tests/Console/CommandsTest.php | 24 ++++++++++++++++++++++++ tests/Console/FieldMakeTest.php | 27 +++++++++++++++++++++++++++ tests/Console/FilterMakeTest.php | 28 ++++++++++++++++++++++++++++ tests/Console/ResourceMakeTest.php | 24 ++++++++++++++++++++++++ tests/Console/TrendMakeTest.php | 24 ++++++++++++++++++++++++ tests/Console/ValueMakeTest.php | 24 ++++++++++++++++++++++++ tests/Console/WidgetMakeTest.php | 24 ++++++++++++++++++++++++ tests/TestCase.php | 3 +++ 9 files changed, 202 insertions(+) create mode 100644 tests/Console/ActionMakeTest.php create mode 100644 tests/Console/CommandsTest.php create mode 100644 tests/Console/FieldMakeTest.php create mode 100644 tests/Console/FilterMakeTest.php create mode 100644 tests/Console/ResourceMakeTest.php create mode 100644 tests/Console/TrendMakeTest.php create mode 100644 tests/Console/ValueMakeTest.php create mode 100644 tests/Console/WidgetMakeTest.php diff --git a/tests/Console/ActionMakeTest.php b/tests/Console/ActionMakeTest.php new file mode 100644 index 00000000..18d03382 --- /dev/null +++ b/tests/Console/ActionMakeTest.php @@ -0,0 +1,24 @@ +artisan('root:action', ['name' => 'TestAction']) + ->assertExitCode(Command::SUCCESS); + + $this->assertFileExists($this->app->path('/Root/Actions/TestAction.php')); + } + + public function tearDown(): void + { + unlink($this->app->path('/Root/Actions/TestAction.php')); + + parent::tearDown(); + } +} diff --git a/tests/Console/CommandsTest.php b/tests/Console/CommandsTest.php new file mode 100644 index 00000000..729f8112 --- /dev/null +++ b/tests/Console/CommandsTest.php @@ -0,0 +1,24 @@ +putFileAs( + '', + UploadedFile::fake()->create('test.chunk'), + 'root-tmp/test.chunk' + ); + + $this->artisan('root:clear-chunks') + ->expectsOutput('1 chunks are cleared!') + ->assertExitCode(Command::SUCCESS); + } +} diff --git a/tests/Console/FieldMakeTest.php b/tests/Console/FieldMakeTest.php new file mode 100644 index 00000000..6aaa5196 --- /dev/null +++ b/tests/Console/FieldMakeTest.php @@ -0,0 +1,27 @@ +artisan('root:field', [ + 'name' => 'TestField', + '--template' => 'foo', + ]) + ->assertExitCode(Command::SUCCESS); + + $this->assertFileExists($this->app->path('/Root/Fields/TestField.php')); + } + + public function tearDown(): void + { + unlink($this->app->path('/Root/Fields/TestField.php')); + + parent::tearDown(); + } +} diff --git a/tests/Console/FilterMakeTest.php b/tests/Console/FilterMakeTest.php new file mode 100644 index 00000000..c430b4c9 --- /dev/null +++ b/tests/Console/FilterMakeTest.php @@ -0,0 +1,28 @@ +artisan('root:filter', [ + 'name' => 'TestFilter', + '--type' => 'select', + '--multiple' => true, + ]) + ->assertExitCode(Command::SUCCESS); + + $this->assertFileExists($this->app->path('/Root/Filters/TestFilter.php')); + } + + public function tearDown(): void + { + unlink($this->app->path('/Root/Filters/TestFilter.php')); + + parent::tearDown(); + } +} diff --git a/tests/Console/ResourceMakeTest.php b/tests/Console/ResourceMakeTest.php new file mode 100644 index 00000000..30f7a55a --- /dev/null +++ b/tests/Console/ResourceMakeTest.php @@ -0,0 +1,24 @@ +artisan('root:resource', ['name' => 'TestResource']) + ->assertExitCode(Command::SUCCESS); + + $this->assertFileExists($this->app->path('/Root/Resources/TestResource.php')); + } + + public function tearDown(): void + { + unlink($this->app->path('/Root/Resources/TestResource.php')); + + parent::tearDown(); + } +} diff --git a/tests/Console/TrendMakeTest.php b/tests/Console/TrendMakeTest.php new file mode 100644 index 00000000..a71d6e3c --- /dev/null +++ b/tests/Console/TrendMakeTest.php @@ -0,0 +1,24 @@ +artisan('root:trend', ['name' => 'TrendWidget']) + ->assertExitCode(Command::SUCCESS); + + $this->assertFileExists($this->app->path('/Root/Widgets/TrendWidget.php')); + } + + public function tearDown(): void + { + unlink($this->app->path('/Root/Widgets/TrendWidget.php')); + + parent::tearDown(); + } +} diff --git a/tests/Console/ValueMakeTest.php b/tests/Console/ValueMakeTest.php new file mode 100644 index 00000000..d169371d --- /dev/null +++ b/tests/Console/ValueMakeTest.php @@ -0,0 +1,24 @@ +artisan('root:value', ['name' => 'ValueWidget']) + ->assertExitCode(Command::SUCCESS); + + $this->assertFileExists($this->app->path('/Root/Widgets/ValueWidget.php')); + } + + public function tearDown(): void + { + unlink($this->app->path('/Root/Widgets/ValueWidget.php')); + + parent::tearDown(); + } +} diff --git a/tests/Console/WidgetMakeTest.php b/tests/Console/WidgetMakeTest.php new file mode 100644 index 00000000..f4ed3f6a --- /dev/null +++ b/tests/Console/WidgetMakeTest.php @@ -0,0 +1,24 @@ +artisan('root:widget', ['name' => 'TestWidget']) + ->assertExitCode(Command::SUCCESS); + + $this->assertFileExists($this->app->path('/Root/Widgets/TestWidget.php')); + } + + public function tearDown(): void + { + unlink($this->app->path('/Root/Widgets/TestWidget.php')); + + parent::tearDown(); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index fe76e941..b04640f3 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -27,5 +27,8 @@ public function setUp(): void Storage::fake('public'); Storage::disk('local')->makeDirectory('root-tmp'); + + $this->app['config']->set('root.media.tmp_dir', Storage::disk('local')->path('root-tmp')); + $this->app['config']->set('root.media.chunk_expiration', 0); } }