-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
122835d
commit 8546347
Showing
6 changed files
with
80 additions
and
20 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
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 |
---|---|---|
@@ -1,25 +1,39 @@ | ||
<?php | ||
|
||
use Leuverink\InjectAssets\Contracts\AssetInjector; | ||
|
||
it('injects assets into head tag', function () { | ||
Route::get('test-inject-in-response', fn () => '<html><head></head></html>'); | ||
|
||
$this->get('test-inject-in-response') | ||
->assertOk() | ||
->assertSee('<!--[MAGIC_TODO-ASSETS]-->', false); | ||
})->todo(); | ||
->assertSee('<!--[TEST_PACKAGE ASSETS]-->', false); | ||
}); | ||
|
||
it('injects assets into html body when no head tag is present', function () { | ||
Route::get('test-inject-in-response', fn () => '<html></html>'); | ||
|
||
$this->get('test-inject-in-response') | ||
->assertOk() | ||
->assertSee('<!--[MAGIC_TODO-ASSETS]-->', false); | ||
})->todo(); | ||
->assertSee('<!--[TEST_PACKAGE ASSETS]-->', false); | ||
}); | ||
|
||
it('doesnt inject assets into responses without a closing html tag', function () { | ||
Route::get('test-inject-in-response', fn () => 'OK'); | ||
|
||
$this->get('test-inject-in-response') | ||
->assertOk() | ||
->assertDontSee('<!--[MAGIC_TODO-ASSETS]-->', false); | ||
})->todo(); | ||
->assertDontSee('<!--[TEST_PACKAGE ASSETS]-->', false); | ||
}); | ||
|
||
it('doesnt inject assets when implementation returns false from enabled method', function () { | ||
$this->partialMock(AssetInjector::class) | ||
->shouldReceive('enabled')->once() | ||
->andReturn(false); | ||
|
||
Route::get('test-inject-in-response', fn () => '<html><head></head></html>'); | ||
|
||
$this->get('test-inject-in-response') | ||
->assertOk() | ||
->assertDontSee('<!--[TEST_PACKAGE ASSETS]-->', false); | ||
}); |
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,23 @@ | ||
<?php | ||
|
||
namespace Tests; | ||
|
||
use Leuverink\InjectAssets\Contracts\AssetInjector; | ||
|
||
class Implement implements AssetInjector | ||
{ | ||
public function identifier(): string | ||
{ | ||
return 'TEST_PACKAGE'; | ||
} | ||
|
||
public function enabled(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function inject(): string | ||
{ | ||
return 'TEST_PACKAGE_ASSETS_INJECTED'; | ||
} | ||
} |
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