Skip to content

Commit

Permalink
console tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Jan 25, 2024
1 parent c4fd580 commit a147520
Show file tree
Hide file tree
Showing 9 changed files with 202 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/Console/ActionMakeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Cone\Root\Tests\Console;

use Cone\Root\Tests\TestCase;
use Illuminate\Console\Command;

class ActionMakeTest extends TestCase
{
public function test_an_action_make_command_creates_action(): void
{
$this->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();
}
}
24 changes: 24 additions & 0 deletions tests/Console/CommandsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Cone\Root\Tests\Console;

use Cone\Root\Tests\TestCase;
use Illuminate\Console\Command;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;

class CommandsTest extends TestCase
{
public function test_a_command_can_clear_chunks(): void
{
Storage::disk('local')->putFileAs(
'',
UploadedFile::fake()->create('test.chunk'),
'root-tmp/test.chunk'
);

$this->artisan('root:clear-chunks')
->expectsOutput('1 chunks are cleared!')
->assertExitCode(Command::SUCCESS);
}
}
27 changes: 27 additions & 0 deletions tests/Console/FieldMakeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Cone\Root\Tests\Console;

use Cone\Root\Tests\TestCase;
use Illuminate\Console\Command;

class FieldMakeTest extends TestCase
{
public function test_a_field_make_command_creates_field(): void
{
$this->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();
}
}
28 changes: 28 additions & 0 deletions tests/Console/FilterMakeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace Cone\Root\Tests\Console;

use Cone\Root\Tests\TestCase;
use Illuminate\Console\Command;

class FilterMakeTest extends TestCase
{
public function test_a_filter_make_command_creates_filter(): void
{
$this->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();
}
}
24 changes: 24 additions & 0 deletions tests/Console/ResourceMakeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Cone\Root\Tests\Console;

use Cone\Root\Tests\TestCase;
use Illuminate\Console\Command;

class ResourceMakeTest extends TestCase
{
public function test_a_resource_make_command_creates_resource(): void
{
$this->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();
}
}
24 changes: 24 additions & 0 deletions tests/Console/TrendMakeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Cone\Root\Tests\Console;

use Cone\Root\Tests\TestCase;
use Illuminate\Console\Command;

class TrendMakeTest extends TestCase
{
public function test_a_trend_make_command_creates_trend_widget(): void
{
$this->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();
}
}
24 changes: 24 additions & 0 deletions tests/Console/ValueMakeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Cone\Root\Tests\Console;

use Cone\Root\Tests\TestCase;
use Illuminate\Console\Command;

class ValueMakeTest extends TestCase
{
public function test_a_value_make_command_creates_value_widget(): void
{
$this->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();
}
}
24 changes: 24 additions & 0 deletions tests/Console/WidgetMakeTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Cone\Root\Tests\Console;

use Cone\Root\Tests\TestCase;
use Illuminate\Console\Command;

class WidgetMakeTest extends TestCase
{
public function test_a_widget_make_command_creates_widget(): void
{
$this->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();
}
}
3 changes: 3 additions & 0 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit a147520

Please sign in to comment.