-
-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathFormModelAssetsTest.php
More file actions
66 lines (51 loc) · 1.59 KB
/
FormModelAssetsTest.php
File metadata and controls
66 lines (51 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
namespace Styde\Html\Tests;
use Styde\Html\FormModel;
class FormModelAssetsTest extends TestCase
{
/** @test */
function render_the_scripts()
{
$form = app(AssetsForm::class);
$this->assertSame(['my-calendar.js', '//cdn.example.com/the-editor.js'], $form->scripts());
$this->assertSame(
'<script src="http://localhost/my-calendar.js"></script>'.
'<script src="//cdn.example.com/the-editor.js"></script>',
$form->renderScripts()->toHtml()
);
}
/** @test */
function render_the_styles()
{
$form = app(AssetsForm::class);
$this->assertSame(['my-calendar.css', '//cdn.example.com/the-editor.css'], $form->styles());
$this->assertSame(
'<link type="text/css" rel="stylesheet" href="http://localhost/my-calendar.css">'
.'<link type="text/css" rel="stylesheet" href="//cdn.example.com/the-editor.css">',
$form->renderStyles()->toHtml()
);
}
}
class AssetsForm extends FormModel
{
public function setup()
{
$this->calendar('starts_at');
$this->calendar('ends_at');
$this->tag('p', 'Not a field');
$this->editor('body');
$this->editor('content');
}
protected function calendar($name)
{
$this->text($name)
->script('my-calendar.js')
->style('my-calendar.css');
}
protected function editor($name)
{
$this->text($name)
->script('//cdn.example.com/the-editor.js')
->style('//cdn.example.com/the-editor.css');
}
}