BaseTest.php
1.89 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace OpenCloud\Tests\Common;
use OpenCloud\Common\Base;
use OpenCloud\Common\Lang;
class MyBase extends Base
{
public $foo;
protected $bar;
private $baz;
private $metadata;
public function setBar($bar)
{
$this->bar = $bar . '!!!';
}
public function getBar()
{
return $this->bar;
}
}
class BaseTest extends \OpenCloud\Tests\OpenCloudTestCase
{
private $my;
public function setupObjects()
{
$this->my = new MyBase;
}
/**
* @expectedException OpenCloud\Common\Exceptions\RuntimeException
*/
public function test_Incorrect_Method()
{
$this->assertNull($this->my->fooBarMethod());
}
/**
* @expectedException OpenCloud\Common\Exceptions\RuntimeException
*/
public function test_Setting_NonExistent_Property()
{
$object = $this->my;
$object->setGhost('foobar');
}
public function test_noslash()
{
$this->assertEquals(Lang::noslash('String/'), 'String');
$this->assertEquals(Lang::noslash('String'), 'String');
}
public function testDebug()
{
$logger = $this->my->getLogger();
$logger->setEnabled(true);
$logger->info("HELLO, WORLD!");
$this->expectOutputRegex('/ELLO/');
}
public function test_Metadata_Populate()
{
$object = $this->my;
$data = (object) array(
'metadata' => array(
'foo' => 'bar'
)
);
$object->populate($data);
$this->assertInstanceOf('OpenCloud\Common\Metadata', $object->getMetadata());
}
public function testSetProperty()
{
$this->my->setBar('hello');
$this->assertEquals('hello!!!', $this->my->getBar());
$this->my->setBaz('goodbye');
$this->assertEquals('goodbye', $this->my->getBaz());
}
}