blessing-skin-server/tests/HomeControllerTest.php

46 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2017-11-19 23:48:56 +08:00
use App\Events\RenderingHeader;
use App\Events\RenderingFooter;
use Illuminate\Support\Facades\Event;
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'))
->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('/');
}
}