2017-10-29 09:19:02 +08:00
|
|
|
<?php
|
|
|
|
|
2017-11-19 23:48:56 +08:00
|
|
|
use App\Events\RenderingHeader;
|
|
|
|
use App\Events\RenderingFooter;
|
|
|
|
use Illuminate\Support\Facades\Event;
|
2017-10-29 09:19:02 +08:00
|
|
|
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
|
|
|
|
|
|
class HomeControllerTest extends TestCase
|
|
|
|
{
|
|
|
|
public function testIndex()
|
|
|
|
{
|
|
|
|
$this->get('/')
|
2018-07-13 15:52:42 +08:00
|
|
|
->assertSee(option_localized('site_name'))
|
|
|
|
->assertSee(option_localized('site_description'))
|
2017-10-29 09:19:02 +08:00
|
|
|
->assertViewHas('home_pic_url', option('home_pic_url'));
|
|
|
|
}
|
2017-11-19 23:48:56 +08:00
|
|
|
|
|
|
|
public function testRenderingHeaderEvent()
|
|
|
|
{
|
|
|
|
Event::listen(RenderingHeader::class, function (RenderingHeader $event) {
|
|
|
|
$event->addContent('testing custom header');
|
|
|
|
});
|
2018-07-13 15:52:42 +08:00
|
|
|
$this->get('/')->assertSee('testing custom header');
|
2017-11-19 23:48:56 +08:00
|
|
|
|
|
|
|
Event::listen(RenderingHeader::class, function (RenderingHeader $event) {
|
|
|
|
$event->addContent(new stdClass());
|
|
|
|
});
|
|
|
|
$this->get('/');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testRenderingFooterEvent()
|
|
|
|
{
|
|
|
|
Event::listen(RenderingFooter::class, function (RenderingFooter $event) {
|
|
|
|
$event->addContent('testing custom footer');
|
|
|
|
});
|
2018-07-13 15:52:42 +08:00
|
|
|
$this->get('/')->assertSee('testing custom footer');
|
2017-11-19 23:48:56 +08:00
|
|
|
|
|
|
|
Event::listen(RenderingFooter::class, function (RenderingFooter $event) {
|
|
|
|
$event->addContent(new stdClass());
|
|
|
|
});
|
|
|
|
$this->get('/');
|
|
|
|
}
|
2017-10-29 09:19:02 +08:00
|
|
|
}
|