-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAbstractModelTest.php
More file actions
executable file
·99 lines (85 loc) · 2.55 KB
/
Copy pathAbstractModelTest.php
File metadata and controls
executable file
·99 lines (85 loc) · 2.55 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
92
93
94
95
96
97
98
99
<?php
require_once './AbstractModel.php';
/**
* Extend the abstract class for testing.
*/
class Document extends AbstractModel {
protected $_fields = array(
'title',
'authors'
);
}
/**
* PHPUnit test case.
*/
class AbstractModelTest extends PHPUnit_Framework_TestCase {
/**
* @test
* @dataProvider createModelInvalidPropertyDataProvider
* @expectedException PropertyNotFoundException
*/
public function createNewModelInvalidPropertyTest ($data) {
$doc = new Document($data);
}
/**
* @test
* @dataProvider createModelDataProvider
*/
public function createNewModelTest ($data) {
$doc = new Document($data);
$this->assertInstanceOf('Document', $doc);
$this->assertInstanceOf('AbstractModel', $doc);
}
/**
* Data provider for the create model test.
*/
public function createModelDataProvider () {
return array(
array(array('title'=>'Another test?', 'authors'=>array('me', 'someone else')))
);
}
/**
* Data provider for the create model test exception.
*/
public static function createModelInvalidPropertyDataProvider () {
return array(
array(array('title'=>'Another test?', 'bogus'=>'blah'))
);
}
/**
* Data provider for the get title test.
*/
public static function getTitleTestDataProvider () {
return array(
array(array('title'=>'Test document', 'authors'=>array('me')), 'Test document'),
array(array('title'=>'Another test?', 'authors'=>array('me', 'someone else')), 'Another test?'),
array(array('title'=>'Testing: some test', 'authors'=>array('A man')), 'Testing: some test'),
array(array('title'=>'Testing!', 'authors'=>array('Another man')), 'Testing!'),
);
}
/**
* Data provider for the set title test.
*/
public static function setTitleTestDataProvider () {
return array(
array('Dormouse survey'),
array('Gentle zoo giant rescues baby bird')
);
}
/**
* @dataProvider getTitleTestDataProvider
*/
public function testGetTitle ($data, $title) {
$doc = new Document($data);
$this->assertEquals($title, $doc->title);
}
/**
* Also testing the magic __get here.
* @dataProvider setTitleTestDataProvider
*/
public function testSetTitle ($title) {
$doc = new Document();
$doc->title = $title;
$this->assertEquals($title, $doc->title);
}
}