-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored tests and started Filesystem class tests
- Loading branch information
1 parent
3b6344c
commit a7ed8ba
Showing
7 changed files
with
77 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
tests/Pages/ResourceTest.php → tests/Unit/Pages/ResourceTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/Pages/TemplateTest.php → tests/Unit/Pages/TemplateTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/Pages/TemplatesRepositoryTest.php → tests/Unit/Pages/TemplatesRepositoryTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters