33
44class ActiveRecordTest extends DatabaseTest
55{
6- public function setUp ($ connection_name =null )
6+ public function set_up ($ connection_name =null )
77 {
8- parent ::setUp ($ connection_name );
8+ parent ::set_up ($ connection_name );
99 $ this ->options = array ('conditions ' => 'blah ' , 'order ' => 'blah ' );
1010 }
1111
12- public function testOptionsIsNot ()
12+ public function test_options_is_not ()
1313 {
14- $ this ->assertFalse (Author::is_options_hash (null ));
15- $ this ->assertFalse (Author::is_options_hash ('' ));
16- $ this ->assertFalse (Author::is_options_hash ('tito ' ));
17- $ this ->assertFalse (Author::is_options_hash (array ()));
18- $ this ->assertFalse (Author::is_options_hash (array (1 ,2 ,3 )));
14+ $ this ->assert_false (Author::is_options_hash (null ));
15+ $ this ->assert_false (Author::is_options_hash ('' ));
16+ $ this ->assert_false (Author::is_options_hash ('tito ' ));
17+ $ this ->assert_false (Author::is_options_hash (array ()));
18+ $ this ->assert_false (Author::is_options_hash (array (1 ,2 ,3 )));
1919 }
2020
2121 /**
2222 * @expectedException ActiveRecord\ActiveRecordException
2323 */
24- public function testOptionsHashWithUnknownKeys () {
25- $ this ->assertFalse (Author::is_options_hash (array ('conditions ' => 'blah ' , 'sharks ' => 'laserz ' , 'dubya ' => 'bush ' )));
24+ public function test_options_hash_with_unknown_keys () {
25+ $ this ->assert_false (Author::is_options_hash (array ('conditions ' => 'blah ' , 'sharks ' => 'laserz ' , 'dubya ' => 'bush ' )));
2626 }
2727
28- public function testOptionsIsHash ()
28+ public function test_options_is_hash ()
2929 {
30- $ this ->assertTrue (Author::is_options_hash ($ this ->options ));
30+ $ this ->assert_true (Author::is_options_hash ($ this ->options ));
3131 }
3232
33- public function testExtractAndValidateOptions () {
33+ public function test_extract_and_validate_options () {
3434 $ args = array ('first ' ,$ this ->options );
35- $ this ->assertEquals ($ this ->options ,Author::extract_and_validate_options ($ args ));
36- $ this ->assertEquals (array ('first ' ),$ args );
35+ $ this ->assert_equals ($ this ->options ,Author::extract_and_validate_options ($ args ));
36+ $ this ->assert_equals (array ('first ' ),$ args );
3737 }
3838
39- public function testExtractAndValidateOptionsWithArrayInArgs () {
39+ public function test_extract_and_validate_options_with_array_in_args () {
4040 $ args = array ('first ' ,array (1 ,2 ),$ this ->options );
41- $ this ->assertEquals ($ this ->options ,Author::extract_and_validate_options ($ args ));
41+ $ this ->assert_equals ($ this ->options ,Author::extract_and_validate_options ($ args ));
4242 }
4343
44- public function testExtractAndValidateOptionsRemovesOptionsHash () {
44+ public function test_extract_and_validate_options_removes_options_hash () {
4545 $ args = array ('first ' ,$ this ->options );
4646 Author::extract_and_validate_options ($ args );
47- $ this ->assertEquals (array ('first ' ),$ args );
47+ $ this ->assert_equals (array ('first ' ),$ args );
4848 }
4949
50- public function testExtractAndValidateOptionsNope () {
50+ public function test_extract_and_validate_options_nope () {
5151 $ args = array ('first ' );
52- $ this ->assertEquals (array (),Author::extract_and_validate_options ($ args ));
53- $ this ->assertEquals (array ('first ' ),$ args );
52+ $ this ->assert_equals (array (),Author::extract_and_validate_options ($ args ));
53+ $ this ->assert_equals (array ('first ' ),$ args );
5454 }
5555
56- public function testExtractAndValidateOptionsNopeBecauseWasntAtEnd () {
56+ public function test_extract_and_validate_options_nope_because_wasnt_at_end () {
5757 $ args = array ('first ' ,$ this ->options ,array (1 ,2 ));
58- $ this ->assertEquals (array (),Author::extract_and_validate_options ($ args ));
58+ $ this ->assert_equals (array (),Author::extract_and_validate_options ($ args ));
5959 }
6060
6161 /**
6262 * @expectedException ActiveRecord\UndefinedPropertyException
6363 */
64- public function testInvalidAttribute ()
64+ public function test_invalid_attribute ()
6565 {
6666 $ author = Author::find ('first ' ,array ('conditions ' => 'author_id=1 ' ));
6767 $ author ->some_invalid_field_name ;
6868 }
6969
70- public function testInvalidAttributes ()
70+ public function test_invalid_attributes ()
7171 {
7272 $ book = Book::find (1 );
7373 try {
@@ -76,114 +76,114 @@ public function testInvalidAttributes()
7676 $ exceptions = explode ("\r\n" , $ e ->getMessage ());
7777 }
7878
79- $ this ->assertEquals (1 , substr_count ($ exceptions [0 ], 'invalid_attribute ' ));
80- $ this ->assertEquals (1 , substr_count ($ exceptions [1 ], 'another_invalid_attribute ' ));
79+ $ this ->assert_equals (1 , substr_count ($ exceptions [0 ], 'invalid_attribute ' ));
80+ $ this ->assert_equals (1 , substr_count ($ exceptions [1 ], 'another_invalid_attribute ' ));
8181 }
8282
83- public function testGetValuesFor ()
83+ public function test_get_values_for ()
8484 {
8585 $ book = Book::find_by_name ('Ancient Art of Main Tanking ' );
8686 $ ret = $ book ->get_values_for (array ('book_id ' ,'author_id ' ));
87- $ this ->assertEquals (array ('book_id ' ,'author_id ' ),array_keys ($ ret ));
88- $ this ->assertEquals (array (1 ,1 ),array_values ($ ret ));
87+ $ this ->assert_equals (array ('book_id ' ,'author_id ' ),array_keys ($ ret ));
88+ $ this ->assert_equals (array (1 ,1 ),array_values ($ ret ));
8989 }
9090
91- public function testHyphenatedColumnNamesToUnderscore ()
91+ public function test_hyphenated_column_names_to_underscore ()
9292 {
9393 $ res = RmBldg::first ();
94- $ this ->assertEquals ('name ' ,$ res ->rm_name );
94+ $ this ->assert_equals ('name ' ,$ res ->rm_name );
9595 }
9696
97- public function testReload ()
97+ public function test_reload ()
9898 {
9999 $ venue = Venue::find (1 );
100- $ this ->assertEquals ('NY ' , $ venue ->state );
100+ $ this ->assert_equals ('NY ' , $ venue ->state );
101101 $ venue ->state = 'VA ' ;
102- $ this ->assertEquals ('VA ' , $ venue ->state );
102+ $ this ->assert_equals ('VA ' , $ venue ->state );
103103 $ venue ->reload ();
104- $ this ->assertEquals ('NY ' , $ venue ->state );
104+ $ this ->assert_equals ('NY ' , $ venue ->state );
105105 }
106106
107- public function testActiveRecordModelHomeNotSet ()
107+ public function test_active_record_model_home_not_set ()
108108 {
109109 $ home = ActiveRecord \Config::instance ()->get_model_directory ();
110110 ActiveRecord \Config::instance ()->set_model_directory (__FILE__ );
111- $ this ->assertEquals (false ,class_exists ('TestAutoload ' ));
111+ $ this ->assert_equals (false ,class_exists ('TestAutoload ' ));
112112
113113 ActiveRecord \Config::instance ()->set_model_directory ($ home );
114114 }
115115
116- public function testAutoLoadWithNamespacedModel ()
116+ public function test_auto_load_with_namespaced_model ()
117117 {
118- $ this ->assertTrue (class_exists ('NamespaceTest\SomeModel ' ));
118+ $ this ->assert_true (class_exists ('NamespaceTest\SomeModel ' ));
119119 }
120120
121- public function testShouldHaveAllColumnAttributesWhenInitializingWithArray ()
121+ public function test_should_have_all_column_attributes_when_initializing_with_array ()
122122 {
123123 $ author = new Author (array ('name ' => 'Tito ' ));
124- $ this ->assertEquals (array ('author_id ' ,'parent_author_id ' ,'name ' ,'updated_at ' ,'created_at ' ,'some_date ' ),array_keys ($ author ->attributes ()));
124+ $ this ->assert_equals (array ('author_id ' ,'parent_author_id ' ,'name ' ,'updated_at ' ,'created_at ' ,'some_date ' ),array_keys ($ author ->attributes ()));
125125 }
126126
127- public function testDefaults ()
127+ public function test_defaults ()
128128 {
129129 $ author = new Author ();
130- $ this ->assertEquals ('default_name ' ,$ author ->name );
130+ $ this ->assert_equals ('default_name ' ,$ author ->name );
131131 }
132132
133- public function testAliasAttributeGetter ()
133+ public function test_alias_attribute_getter ()
134134 {
135135 $ venue = Venue::find (1 );
136- $ this ->assertEquals ($ venue ->marquee , $ venue ->name );
137- $ this ->assertEquals ($ venue ->mycity , $ venue ->city );
136+ $ this ->assert_equals ($ venue ->marquee , $ venue ->name );
137+ $ this ->assert_equals ($ venue ->mycity , $ venue ->city );
138138 }
139139
140- public function testAliasAttributeSetter ()
140+ public function test_alias_attribute_setter ()
141141 {
142142 $ venue = Venue::find (1 );
143143 $ venue ->marquee = 'new name ' ;
144- $ this ->assertEquals ($ venue ->marquee , 'new name ' );
145- $ this ->assertEquals ($ venue ->marquee , $ venue ->name );
144+ $ this ->assert_equals ($ venue ->marquee , 'new name ' );
145+ $ this ->assert_equals ($ venue ->marquee , $ venue ->name );
146146
147147 $ venue ->name = 'another name ' ;
148- $ this ->assertEquals ($ venue ->name , 'another name ' );
149- $ this ->assertEquals ($ venue ->marquee , $ venue ->name );
148+ $ this ->assert_equals ($ venue ->name , 'another name ' );
149+ $ this ->assert_equals ($ venue ->marquee , $ venue ->name );
150150 }
151151
152- public function testAliasFromMassAttributes ()
152+ public function test_alias_from_mass_attributes ()
153153 {
154154 $ venue = new Venue (array ('marquee ' => 'meme ' , 'id ' => 123 ));
155- $ this ->assertEquals ('meme ' ,$ venue ->name );
156- $ this ->assertEquals ($ venue ->marquee ,$ venue ->name );
155+ $ this ->assert_equals ('meme ' ,$ venue ->name );
156+ $ this ->assert_equals ($ venue ->marquee ,$ venue ->name );
157157 }
158158
159- public function testAttrAccessible ()
159+ public function test_attr_accessible ()
160160 {
161161 $ book = new BookAttrAccessible (array ('name ' => 'should not be set ' , 'author_id ' => 1 ));
162- $ this ->assertNull ($ book ->name );
163- $ this ->assertEquals (1 ,$ book ->author_id );
162+ $ this ->assert_null ($ book ->name );
163+ $ this ->assert_equals (1 ,$ book ->author_id );
164164 $ book ->name = 'test ' ;
165- $ this ->assertEquals ('test ' , $ book ->name );
165+ $ this ->assert_equals ('test ' , $ book ->name );
166166 }
167167
168- public function testAttrProtected ()
168+ public function test_attr_protected ()
169169 {
170170 $ book = new BookAttrAccessible (array ('book_id ' => 999 ));
171- $ this ->assertNull ($ book ->book_id );
171+ $ this ->assert_null ($ book ->book_id );
172172 $ book ->book_id = 999 ;
173- $ this ->assertEquals (999 , $ book ->book_id );
173+ $ this ->assert_equals (999 , $ book ->book_id );
174174 }
175175
176- public function testIsset ()
176+ public function test_isset ()
177177 {
178178 $ book = new Book ();
179- $ this ->assertTrue (isset ($ book ->name ));
180- $ this ->assertFalse (isset ($ book ->sharks ));
179+ $ this ->assert_true (isset ($ book ->name ));
180+ $ this ->assert_false (isset ($ book ->sharks ));
181181 }
182182
183- public function testReadonlyOnlyHaltOnWriteMethod ()
183+ public function test_readonly_only_halt_on_write_method ()
184184 {
185185 $ book = Book::first (array ('readonly ' => true ));
186- $ this ->assertTrue ($ book ->is_readonly ());
186+ $ this ->assert_true ($ book ->is_readonly ());
187187
188188 try {
189189 $ book ->save ();
@@ -192,44 +192,44 @@ public function testReadonlyOnlyHaltOnWriteMethod()
192192 }
193193
194194 $ book ->name = 'some new name ' ;
195- $ this ->assertEquals ($ book ->name , 'some new name ' );
195+ $ this ->assert_equals ($ book ->name , 'some new name ' );
196196 }
197197
198- public function testCastWhenUsingSetter ()
198+ public function test_cast_when_using_setter ()
199199 {
200200 $ book = new Book ();
201201 $ book ->book_id = '1 ' ;
202- $ this ->assertSame (1 ,$ book ->book_id );
202+ $ this ->assert_same (1 ,$ book ->book_id );
203203 }
204204
205- public function testCastWhenLoading ()
205+ public function test_cast_when_loading ()
206206 {
207207 $ book = Book::find (1 );
208- $ this ->assertSame (1 ,$ book ->book_id );
209- $ this ->assertSame ('Ancient Art of Main Tanking ' ,$ book ->name );
208+ $ this ->assert_same (1 ,$ book ->book_id );
209+ $ this ->assert_same ('Ancient Art of Main Tanking ' ,$ book ->name );
210210 }
211211
212- public function testCastDefaults ()
212+ public function test_cast_defaults ()
213213 {
214214 $ book = new Book ();
215- $ this ->assertSame (0.0 ,$ book ->special );
215+ $ this ->assert_same (0.0 ,$ book ->special );
216216 }
217217
218- public function testTransactionCommitted ()
218+ public function test_transaction_committed ()
219219 {
220220 $ original = Author::count ();
221221 Author::transaction (function () { Author::create (array ("name " => "blah " )); });
222- $ this ->assertEquals ($ original +1 ,Author::count ());
222+ $ this ->assert_equals ($ original +1 ,Author::count ());
223223 }
224224
225- public function testTransactionCommittedWhenReturningTrue ()
225+ public function test_transaction_committed_when_returning_true ()
226226 {
227227 $ original = Author::count ();
228228 Author::transaction (function () { Author::create (array ("name " => "blah " )); return true ; });
229- $ this ->assertEquals ($ original +1 ,Author::count ());
229+ $ this ->assert_equals ($ original +1 ,Author::count ());
230230 }
231231
232- public function testTransactionRolledbackByReturningFalse ()
232+ public function test_transaction_rolledback_by_returning_false ()
233233 {
234234 $ original = Author::count ();
235235
@@ -239,12 +239,12 @@ public function testTransactionRolledbackByReturningFalse()
239239 return false ;
240240 });
241241
242- $ this ->assertEquals ($ original ,Author::count ());
242+ $ this ->assert_equals ($ original ,Author::count ());
243243 }
244244
245245 // TODO this doesn't work for some reason
246246 // TODO the exception is not being caught from within Model::transaction
247- public function testTransactionRolledbackByThrowingException ()
247+ public function test_transaction_rolledback_by_throwing_exception ()
248248 {
249249 /*
250250 $original = Author::count();
@@ -261,39 +261,39 @@ public function testTransactionRolledbackByThrowingException()
261261 {
262262 }
263263
264- $this->assertEquals ($original,Author::count());
264+ $this->assert_equals ($original,Author::count());
265265 */
266266 }
267267
268- public function testDelegate ()
268+ public function test_delegate ()
269269 {
270270 $ event = Event::first ();
271- $ this ->assertEquals ($ event ->venue ->state ,$ event ->state );
272- $ this ->assertEquals ($ event ->venue ->address ,$ event ->address );
271+ $ this ->assert_equals ($ event ->venue ->state ,$ event ->state );
272+ $ this ->assert_equals ($ event ->venue ->address ,$ event ->address );
273273 }
274274
275- public function testDelegatePrefix ()
275+ public function test_delegate_prefix ()
276276 {
277277 $ event = Event::first ();
278- $ this ->assertEquals ($ event ->host ->name ,$ event ->woot_name );
278+ $ this ->assert_equals ($ event ->host ->name ,$ event ->woot_name );
279279 }
280280
281- public function testDelegateReturnsNullIfRelationshipDoesNotExist ()
281+ public function test_delegate_returns_null_if_relationship_does_not_exist ()
282282 {
283283 $ event = new Event ();
284- $ this ->assertNull ($ event ->state );
284+ $ this ->assert_null ($ event ->state );
285285 }
286286
287- public function testDelegateSetter ()
287+ public function test_delegate_setter ()
288288 {
289289 $ event = Event::first ();
290290 $ event ->state = 'MEXICO ' ;
291- $ this ->assertEquals ('MEXICO ' ,$ event ->venue ->state );
291+ $ this ->assert_equals ('MEXICO ' ,$ event ->venue ->state );
292292 }
293293
294- public function testTableNameWithUnderscores ()
294+ public function test_table_name_with_underscores ()
295295 {
296- $ this ->assertNotNull (AwesomePerson::first ());
296+ $ this ->assert_not_null (AwesomePerson::first ());
297297 }
298298};
299299?>
0 commit comments