fix tests of plugin hook

This commit is contained in:
Pig Fang 2018-07-13 16:10:23 +08:00
parent 4e6478c8f9
commit 4c44fa47cd

View File

@ -12,44 +12,42 @@ class HookTest extends TestCase
'icon' => 'fa-book' 'icon' => 'fa-book'
]); ]);
$this->actAs('normal') $this->actAs('normal')
->visit('/user') ->get('/user')
->see('Go to closet') ->assertSee('Go to closet')
->see('/user/closet') ->assertSee('/user/closet')
->see('fa-book') ->assertSee('fa-book');
->click('Go to closet')
->seePageIs('/user/closet');
} }
public function testRegisterPluginTransScripts() public function testRegisterPluginTransScripts()
{ {
Hook::registerPluginTransScripts('example-plugin'); Hook::registerPluginTransScripts('example-plugin');
$this->get('/') $this->get('/')
->see('example-plugin/lang/en/locale.js'); ->assertSee('example-plugin/lang/en/locale.js');
} }
public function testAddStyleFileToPage() public function testAddStyleFileToPage()
{ {
Hook::addStyleFileToPage('/style/all'); Hook::addStyleFileToPage('/style/all');
$this->visit('/') $this->get('/')
->see('<link rel="stylesheet" href="/style/all">'); ->assertSee('<link rel="stylesheet" href="/style/all">');
Hook::addStyleFileToPage('/style/pattern', ['skinlib']); Hook::addStyleFileToPage('/style/pattern', ['skinlib']);
$this->visit('/') $this->get('/')
->dontSee('<link rel="stylesheet" href="/style/pattern">'); ->assertDontSee('<link rel="stylesheet" href="/style/pattern">');
$this->visit('/skinlib') $this->get('/skinlib')
->see('<link rel="stylesheet" href="/style/pattern">'); ->assertSee('<link rel="stylesheet" href="/style/pattern">');
} }
public function testAddScriptFileToPage() public function testAddScriptFileToPage()
{ {
Hook::addScriptFileToPage('/script/all'); Hook::addScriptFileToPage('/script/all');
$this->visit('/') $this->get('/')
->see('<script src="/script/all"></script>'); ->assertSee('<script src="/script/all"></script>');
Hook::addScriptFileToPage('/script/pattern', ['skinlib']); Hook::addScriptFileToPage('/script/pattern', ['skinlib']);
$this->visit('/') $this->get('/')
->dontSee('<script src="/script/pattern"></script>'); ->assertDontSee('<script src="/script/pattern"></script>');
$this->visit('/skinlib') $this->get('/skinlib')
->see('<script src="/script/pattern"></script>'); ->assertSee('<script src="/script/pattern"></script>');
} }
} }