-
Notifications
You must be signed in to change notification settings - Fork 178
/
DataTest.php
59 lines (48 loc) · 1.74 KB
/
DataTest.php
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
<?php
declare(strict_types=1);
namespace League\Plates\Tests\Template;
use League\Plates\Template\Data;
use PHPUnit\Framework\TestCase;
class DataTest extends TestCase
{
private $template_data;
protected function setUp(): void
{
$this->template_data = new Data();
}
public function testCanCreateInstance()
{
$this->assertInstanceOf(Data::class, $this->template_data);
}
public function testAddDataToAllTemplates()
{
$this->template_data->add(array('name' => 'Jonathan'));
$data = $this->template_data->get();
$this->assertSame('Jonathan', $data['name']);
}
public function testAddDataToOneTemplate()
{
$this->template_data->add(array('name' => 'Jonathan'), 'template');
$data = $this->template_data->get('template');
$this->assertSame('Jonathan', $data['name']);
}
public function testAddDataToOneTemplateAgain()
{
$this->template_data->add(array('firstname' => 'Jonathan'), 'template');
$this->template_data->add(array('lastname' => 'Reinink'), 'template');
$data = $this->template_data->get('template');
$this->assertSame('Reinink', $data['lastname']);
}
public function testAddDataToSomeTemplates()
{
$this->template_data->add(array('name' => 'Jonathan'), array('template1', 'template2'));
$data = $this->template_data->get('template1');
$this->assertSame('Jonathan', $data['name']);
}
public function testAddDataWithInvalidTemplateFileType()
{
// The templates variable must be null, an array or a string, integer given.
$this->expectException(\LogicException::class);
$this->template_data->add(array('name' => 'Jonathan'), 123);
}
}