-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
118 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
vendor | ||
.phpunit.result.cache | ||
.phpunit.result.cache | ||
.phpunit.cache |
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
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,62 @@ | ||
<?php | ||
|
||
namespace TallComponents\Tests; | ||
|
||
use Livewire\LivewireServiceProvider; | ||
use TallComponents\TallComponentsServiceProvider; | ||
|
||
class TestCase extends \Orchestra\Testbench\TestCase | ||
{ | ||
/** | ||
* @return void | ||
*/ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->cleanState(); | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function tearDown(): void | ||
{ | ||
$this->cleanState(); | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* @param \Illuminate\Foundation\Application $app | ||
* | ||
* @return void | ||
*/ | ||
public function getEnvironmentSetUp($app) | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @param \Illuminate\Foundation\Application $app | ||
* | ||
* @return array | ||
*/ | ||
public function getPackageProviders($app) | ||
{ | ||
return [ | ||
LivewireServiceProvider::class, | ||
TallComponentsServiceProvider::class, | ||
]; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
private function cleanState() | ||
{ | ||
if (file_exists(resource_path('/views/components/tc/modal.blade.php'))) { | ||
unlink(resource_path('/views/components/tc/modal.blade.php')); | ||
rmdir(resource_path('/views/components/tc')); | ||
rmdir(resource_path('/views/components/')); | ||
} | ||
} | ||
} |
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,45 @@ | ||
<?php | ||
|
||
namespace TallComponents\Tests\Unit; | ||
|
||
use Illuminate\Support\Facades\File; | ||
use TallComponents\Tests\TestCase; | ||
|
||
class PublishViewsTest extends TestCase | ||
{ | ||
/** @test */ | ||
public function test_publish_view_for_modal_when_not_exists() | ||
{ | ||
mkdir(resource_path('views/components/tc'), 0777, true); | ||
|
||
$this->assertFalse(file_exists(resource_path('views/components/tc/modal.blade.php'))); | ||
|
||
$this->artisan('vendor:publish --tag="tall-components-views"'); | ||
|
||
$this->assertTrue(file_exists(resource_path('views/components/tc/modal.blade.php'))); | ||
|
||
$this->assertEquals( | ||
file_get_contents(__DIR__.'/../../resources/views/components/modal.blade.php'), | ||
file_get_contents(resource_path('views/components/tc/modal.blade.php')) | ||
); | ||
} | ||
|
||
/** @test */ | ||
public function test_publish_view_for_modal_when_already_exists() | ||
{ | ||
mkdir(resource_path('views/components/tc'), 0777, true); | ||
|
||
$this->assertFalse(file_exists(resource_path('views/components/tc/modal.blade.php'))); | ||
|
||
File::put(resource_path('views/components/tc/').'modal.blade.php', 'Views test'); | ||
|
||
$this->artisan('vendor:publish --tag="tall-components-views"'); | ||
|
||
$this->assertTrue(file_exists(resource_path('views/components/tc/modal.blade.php'))); | ||
|
||
$this->assertEquals( | ||
'Views test', | ||
file_get_contents(resource_path('views/components/tc/modal.blade.php')) | ||
); | ||
} | ||
} |