blob: 554670f62ff5b2144ee301096b700e8348a31043 (
plain)
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
67
68
69
70
|
<?php
namespace SSRSTest\Object;
use SSRS\Object\CatalogItems;
use SSRS\Object\CatalogItem;
/**
* Description of CatalogItemsTest
*
* @author arron
*/
class CatalogItemsTest extends \PHPUnit_Framework_TestCase {
public function testSetCatalogItems() {
$catalogItem1 = new \stdClass;
$catalogItem1->ID = '1386fc6d-9c58-489f-adea-081146b62799';
$catalogItem1->Name = 'Reference Report';
$catalogItem1->Path = '/Reports/Reference Report';
$catalogItem1->TypeName = 'Report';
$catalogItem1->Size = '234413';
$catalogItem1->CreationDate = '2011-03-03T12:32:57.063';
$catalogItem1->ModifiedDate = '2011-03-03T12:51:12.05';
$catalogItem1->CreatedBy = 'MSSQL\WebAccount';
$catalogItem1->ModifiedBy = 'MSSQL\WebAccount';
$data = new \stdClass;
$data->CatalogItems = new \stdClass;
$data->CatalogItems->CatalogItem = array($catalogItem1);
$expected = new CatalogItems();
$expected->addCatalogItem(new CatalogItem($catalogItem1));
$object = new CatalogItems($data);
$this->assertEquals($expected, $object);
}
/**
* @expectedException PHPUnit_Framework_Error
*/
public function testPassingInvalidObjectToAddCatalogItemThrowsError() {
$object = new CatalogItems();
$object->addCatalogItem(new \stdClass());
}
public function testCatalogItemsEmptyArrayOnInit() {
$object = new CatalogItems();
$this->assertEquals(array(), $object->CatalogItems);
}
public function testAddCatalogItem() {
$object = new CatalogItems();
$object->addCatalogItem(new CatalogItem());
$this->assertEquals(1, count($object->CatalogItems));
}
public function testSetCatalogItemsKeepsCurrentItems() {
$dummy = new \stdClass;
$dummy->CatalogItem[] = new CatalogItem();
$object = new CatalogItems();
$object->setCatalogItems($dummy);
$this->assertEquals(1, count($object->CatalogItems));
$object->setCatalogItems($dummy);
$this->assertEquals(2, count($object->CatalogItems));
}
}
|