blessing-skin-server/tests/HomeControllerTest.php

46 lines
1.3 KiB
PHP
Raw Normal View History

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