3
* Spring Signage Ltd - http://www.springsignage.com
4
* Copyright (C) 2015 Spring Signage Ltd
8
namespace Xibo\Tests\Integration;
9
use Xibo\Helper\Random;
10
use Xibo\OAuth2\Client\Entity\XiboLayout;
11
use Xibo\Tests\LocalWebTestCase;
17
class TemplateTest extends LocalWebTestCase
22
public function testListAll()
24
$this->client->get('/template');
26
$this->assertSame(200, $this->client->response->status());
27
$this->assertNotEmpty($this->client->response->body());
28
$object = json_decode($this->client->response->body());
29
$this->assertObjectHasAttribute('data', $object);
35
public function testAdd()
37
# Create random name and new layout
38
$name1 = Random::generateString(8, 'phpunit');
39
$layout = (new XiboLayout($this->getEntityProvider()))->create($name1, 'phpunit description', '', 9);
40
# Generate second random name
41
$name2 = Random::generateString(8, 'phpunit');
42
# Create template using our layout and new name
43
$this->client->post('/template/' . $layout->layoutId, [
46
'tags' => $layout->tags,
47
'description' => $layout->description
50
$this->assertSame(200, $this->client->response->status(), $this->client->response->body());
51
$object = json_decode($this->client->response->body());
52
$this->assertObjectHasAttribute('data', $object);
53
$this->assertObjectHasAttribute('id', $object);
54
# Check if it has edited name
55
$this->assertSame($name2, $object->data->layout);
56
$templateId = $object->id;
57
# delete template as we no longer need it
58
$template = (new XiboLayout($this->getEntityProvider()))->getByTemplateId($object->id);
60
# delete layout as we no longer need it