]> BookStack Code Mirror - bookstack/blob - tests/Entity/MarkdownTest.php
Update passwords.php
[bookstack] / tests / Entity / MarkdownTest.php
1 <?php namespace Tests;
2
3 class MarkdownTest extends BrowserKitTest
4 {
5     protected $page;
6
7     public function setUp()
8     {
9         parent::setUp();
10         $this->page = \BookStack\Entities\Page::first();
11     }
12
13     protected function setMarkdownEditor()
14     {
15         $this->setSettings(['app-editor' => 'markdown']);
16     }
17
18     public function test_default_editor_is_wysiwyg()
19     {
20         $this->assertEquals(setting('app-editor'), 'wysiwyg');
21         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
22             ->pageHasElement('#html-editor');
23     }
24     
25     public function test_markdown_setting_shows_markdown_editor()
26     {
27         $this->setMarkdownEditor();
28         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
29             ->pageNotHasElement('#html-editor')
30             ->pageHasElement('#markdown-editor');
31     }
32
33     public function test_markdown_content_given_to_editor()
34     {
35         $this->setMarkdownEditor();
36         $mdContent = '# hello. This is a test';
37         $this->page->markdown = $mdContent;
38         $this->page->save();
39         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
40             ->seeInField('markdown', $mdContent);
41     }
42
43     public function test_html_content_given_to_editor_if_no_markdown()
44     {
45         $this->setMarkdownEditor();
46         $this->asAdmin()->visit($this->page->getUrl() . '/edit')
47             ->seeInField('markdown', $this->page->html);
48     }
49
50 }
Morty Proxy This is a proxified and sanitized view of the page, visit original site.