Skip to content

Commit

Permalink
Refactored tests and started Filesystem class tests
Browse files Browse the repository at this point in the history
  • Loading branch information
voidgraphics committed Feb 15, 2019
1 parent 3b6344c commit a7ed8ba
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\Pages;
namespace Tests\Unit\Pages;

use FakeTestApp\Nova\Templates\Test;
use Illuminate\Routing\Route;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\Pages;
namespace Tests\Unit\Pages;

use FakeTestApp\Nova\Templates\Test;
use Orchestra\Testbench\TestCase;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace Tests\Pages;
namespace Tests\Unit\Pages;

use FakeTestApp\Nova\Templates\Test;
use Illuminate\Routing\Route;
use Laravel\Nova\Fields\Text;
use Laravel\Nova\Http\Requests\NovaRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\Pages;
namespace Tests\Unit\Pages;

use Carbon\Carbon;
use FakeTestApp\Nova\Templates\Test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Tests\Pages;
namespace Tests\Unit\Pages;

use FakeTestApp\Nova\Templates\Test;
use Orchestra\Testbench\TestCase;
Expand Down
70 changes: 70 additions & 0 deletions tests/Unit/Sources/FilesystemTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

namespace Tests\Unit\Sources;

use FakeTestApp\Nova\Templates\Test;
use Orchestra\Testbench\TestCase;
use Whitecube\NovaPage\Pages\Query;
use Whitecube\NovaPage\Pages\TemplatesRepository;
use Whitecube\NovaPage\Sources\Filesystem;

class FilesystemTest extends TestCase {

protected function getPackageProviders($app)
{
return ['Whitecube\NovaPage\NovaPageServiceProvider'];
}

/**
* Define environment setup.
*
* @param \Illuminate\Foundation\Application $app
* @return void
*/
protected function getEnvironmentSetUp($app)
{
$app['config']->set('novapage.sources.filesystem.path', __dir__ . '/../../test-application/resources/lang/{type}/{key}.json');
}

/** @test */
public function can_create_an_instance()
{
$instance = new Filesystem();
$this->assertInstanceOf(Filesystem::class, $instance);
}

/** @test */
public function can_return_its_name()
{
$instance = new Filesystem();
$this->assertSame('filesystem', $instance->getName());
}

/** @test */
public function can_set_its_path_via_config()
{
$instance = (new class extends Filesystem {
public function getPath()
{
return $this->path;
}
});

$instance->setConfig([
'path' => 'test'
]);

$this->assertSame('test', $instance->getPath());
}

/** @test */
public function can_fetch_the_values_of_a_page()
{
$instance = new Filesystem();
$template = new Test('test', 'route', false);
$instance->setConfig(config('novapage.sources.' . $instance->getName()));
$data = $instance->fetch($template);
$this->assertCount(1, $data['attributes']);
$this->assertSame('Test value', $data['attributes']['test_field']);
}
}
2 changes: 1 addition & 1 deletion tests/test-application/resources/lang/route/test.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"title": "Test page title",
"create_at": "",
"created_at": "",
"updated_at": "",
"attributes": {
"test_field": "Test value"
Expand Down

0 comments on commit a7ed8ba

Please sign in to comment.