Update tests for HomeController

This commit is contained in:
Pig Fang 2017-11-19 23:48:56 +08:00
parent 2e5c1f7890
commit 163396c6d9

View File

@ -1,5 +1,8 @@
<?php
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;
@ -20,4 +23,30 @@ class HomeControllerTest extends TestCase
$this->visit('/')->click('Homepage')->seePageIs('/');
$this->visit('/')->click('Skin Library')->seePageIs('/skinlib');
}
public function testRenderingHeaderEvent()
{
Event::listen(RenderingHeader::class, function (RenderingHeader $event) {
$event->addContent('testing custom header');
});
$this->visit('/')->see('testing custom header');
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');
});
$this->visit('/')->see('testing custom footer');
Event::listen(RenderingFooter::class, function (RenderingFooter $event) {
$event->addContent(new stdClass());
});
$this->get('/');
}
}