-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sam Poyigi <[email protected]>
- Loading branch information
Showing
8 changed files
with
212 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 was deleted.
Oops, something went wrong.
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,34 @@ | ||
<?php | ||
|
||
namespace Igniter\Frontend\Tests; | ||
|
||
use Igniter\Frontend\Extension; | ||
|
||
it('registers permissions', function() { | ||
$extension = new Extension(app()); | ||
|
||
$permissions = $extension->registerPermissions(); | ||
|
||
expect($permissions)->toHaveKeys([ | ||
'Igniter.FrontEnd.ManageSettings', | ||
'Igniter.FrontEnd.ManageBanners', | ||
'Igniter.FrontEnd.ManageSlideshow', | ||
]); | ||
}); | ||
|
||
it('registers navigation', function() { | ||
$extension = new Extension(app()); | ||
|
||
$navigation = $extension->registerNavigation(); | ||
|
||
expect($navigation)->toHaveKeys(['design']) | ||
->and($navigation['design']['child'])->toHaveKeys(['sliders']); | ||
}); | ||
|
||
it('registers mail templates', function() { | ||
$extension = new Extension(app()); | ||
|
||
$templates = $extension->registerMailTemplates(); | ||
|
||
expect($templates)->toHaveKey('igniter.frontend::mail.contact'); | ||
}); |
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,85 @@ | ||
<?php | ||
|
||
namespace Igniter\Frontend\Tests\Http\Controllers; | ||
|
||
use Igniter\Frontend\Models\Banner; | ||
|
||
it('loads banners page', function() { | ||
actingAsSuperUser() | ||
->get(route('igniter.frontend.banners')) | ||
->assertOk(); | ||
}); | ||
|
||
it('loads create banner page', function() { | ||
actingAsSuperUser() | ||
->get(route('igniter.frontend.banners', ['slug' => 'create'])) | ||
->assertOk(); | ||
}); | ||
|
||
it('loads edit banner page', function() { | ||
$banner = Banner::create(); | ||
|
||
actingAsSuperUser() | ||
->get(route('igniter.frontend.banners', ['slug' => 'edit/'.$banner->getKey()])) | ||
->assertOk(); | ||
}); | ||
|
||
it('loads banner preview page', function() { | ||
$banner = Banner::create(); | ||
|
||
actingAsSuperUser() | ||
->get(route('igniter.frontend.banners', ['slug' => 'preview/'.$banner->getKey()])) | ||
->assertOk(); | ||
}); | ||
|
||
it('creates banner', function() { | ||
actingAsSuperUser() | ||
->post(route('igniter.frontend.banners', ['slug' => 'create']), [ | ||
'Banner' => [ | ||
'name' => 'Created Banner', | ||
'code' => 'banner-code', | ||
'custom_code' => '<h1>Updated Banner</h1>', | ||
'language_id' => 1, | ||
'status' => 1, | ||
], | ||
], [ | ||
'X-Requested-With' => 'XMLHttpRequest', | ||
'X-IGNITER-REQUEST-HANDLER' => 'onSave', | ||
]); | ||
|
||
expect(Banner::where('name', 'Created Banner')->exists())->toBeTrue(); | ||
}); | ||
|
||
it('updates banner', function() { | ||
$banner = Banner::create(); | ||
|
||
actingAsSuperUser() | ||
->post(route('igniter.frontend.banners', ['slug' => 'edit/'.$banner->getKey()]), [ | ||
'Banner' => [ | ||
'name' => 'Updated Banner', | ||
'code' => 'banner-code', | ||
'custom_code' => '<h1>Updated Banner</h1>', | ||
'language_id' => 1, | ||
'status' => 1, | ||
], | ||
], [ | ||
'X-Requested-With' => 'XMLHttpRequest', | ||
'X-IGNITER-REQUEST-HANDLER' => 'onSave', | ||
]); | ||
|
||
expect(Banner::where('name', 'Updated Banner')->exists())->toBeTrue(); | ||
}); | ||
|
||
it('deletes banner', function() { | ||
$banner = Banner::create(); | ||
|
||
actingAsSuperUser() | ||
->post(route('igniter.frontend.banners', ['slug' => 'edit/'.$banner->getKey()]), [], [ | ||
'X-Requested-With' => 'XMLHttpRequest', | ||
'X-IGNITER-REQUEST-HANDLER' => 'onDelete', | ||
]); | ||
|
||
expect(Banner::find($banner->getKey()))->toBeNull(); | ||
}); | ||
|
||
|
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,89 @@ | ||
<?php | ||
|
||
namespace Igniter\Frontend\Tests\Http\Controllers; | ||
|
||
use Igniter\Frontend\Models\Slider; | ||
use Igniter\User\Models\User; | ||
|
||
it('loads sliders page', function() { | ||
actingAsSuperUser() | ||
->get(route('igniter.frontend.sliders')) | ||
->assertOk(); | ||
}); | ||
|
||
it('loads create slider page', function() { | ||
actingAsSuperUser() | ||
->get(route('igniter.frontend.sliders', ['slug' => 'create'])) | ||
->assertOk(); | ||
}); | ||
|
||
it('loads edit slider page', function() { | ||
$slider = Slider::create(); | ||
|
||
actingAsSuperUser() | ||
->get(route('igniter.frontend.sliders', ['slug' => 'edit/'.$slider->getKey()])) | ||
->assertOk(); | ||
}); | ||
|
||
it('loads slider preview page', function() { | ||
$slider = Slider::create(); | ||
|
||
actingAsSuperUser() | ||
->get(route('igniter.frontend.sliders', ['slug' => 'preview/'.$slider->getKey()])) | ||
->assertOk(); | ||
}); | ||
|
||
it('creates slider', function() { | ||
actingAsSuperUser() | ||
->post(route('igniter.frontend.sliders', ['slug' => 'create']), [ | ||
'Slider' => [ | ||
'name' => 'Created Slider', | ||
'code' => 'slider-code', | ||
'images' => [ | ||
'path/to/image.jpg', | ||
] | ||
], | ||
], [ | ||
'X-Requested-With' => 'XMLHttpRequest', | ||
'X-IGNITER-REQUEST-HANDLER' => 'onSave', | ||
]); | ||
|
||
expect(Slider::where('name', 'Created Slider')->exists())->toBeTrue(); | ||
}); | ||
|
||
it('updates slider', function() { | ||
$slider = Slider::create(); | ||
|
||
actingAsSuperUser() | ||
->post(route('igniter.frontend.sliders', ['slug' => 'edit/'.$slider->getKey()]), [ | ||
'Slider' => [ | ||
'name' => 'Updated Slider', | ||
'code' => 'slider-code', | ||
'images' => [ | ||
'path/to/image.jpg', | ||
] | ||
], | ||
], [ | ||
'X-Requested-With' => 'XMLHttpRequest', | ||
'X-IGNITER-REQUEST-HANDLER' => 'onSave', | ||
]); | ||
|
||
expect(Slider::where('name', 'Updated Slider')->exists())->toBeTrue(); | ||
}); | ||
|
||
it('deletes slider', function() { | ||
$slider = Slider::create(); | ||
|
||
actingAsSuperUser() | ||
->post(route('igniter.frontend.sliders', ['slug' => 'edit/'.$slider->getKey()]), [], [ | ||
'X-Requested-With' => 'XMLHttpRequest', | ||
'X-IGNITER-REQUEST-HANDLER' => 'onDelete', | ||
]); | ||
|
||
expect(Slider::find($slider->getKey()))->toBeNull(); | ||
}); | ||
|
||
function actingAsSuperUser() | ||
{ | ||
return test()->actingAs(User::factory()->superUser()->create(), 'igniter-admin'); | ||
} |
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 +1,3 @@ | ||
<?php | ||
|
||
uses(SamPoyigi\Testbench\TestCase::class)->in(__DIR__); |
This file was deleted.
Oops, something went wrong.