@@ -123,30 +123,30 @@ public function test_to_xml()
123
123
$ this ->assert_equals ($ book ->attributes (),get_object_vars (new SimpleXMLElement ($ book ->to_xml ())));
124
124
}
125
125
126
- public function test_to_array ()
127
- {
128
- $ book = Book::find (1 );
126
+ public function test_to_array ()
127
+ {
128
+ $ book = Book::find (1 );
129
129
$ array = $ book ->to_array ();
130
130
$ this ->assert_equals ($ book ->attributes (), $ array );
131
- }
131
+ }
132
132
133
- public function test_to_array_include_root ()
134
- {
133
+ public function test_to_array_include_root ()
134
+ {
135
135
ActiveRecord \ArraySerializer::$ include_root = true ;
136
- $ book = Book::find (1 );
136
+ $ book = Book::find (1 );
137
137
$ array = $ book ->to_array ();
138
- $ book_attributes = array ('book ' => $ book ->attributes ());
138
+ $ book_attributes = array ('book ' => $ book ->attributes ());
139
139
$ this ->assert_equals ($ book_attributes , $ array );
140
- }
140
+ }
141
141
142
- public function test_to_array_except ()
143
- {
144
- $ book = Book::find (1 );
142
+ public function test_to_array_except ()
143
+ {
144
+ $ book = Book::find (1 );
145
145
$ array = $ book ->to_array (array ('except ' => array ('special ' )));
146
146
$ book_attributes = $ book ->attributes ();
147
147
unset($ book_attributes ['special ' ]);
148
148
$ this ->assert_equals ($ book_attributes , $ array );
149
- }
149
+ }
150
150
151
151
public function test_works_with_datetime ()
152
152
{
@@ -166,49 +166,49 @@ public function test_only_method()
166
166
$ this ->assert_contains ('<sharks>lasers</sharks> ' , Author::first ()->to_xml (array ('only_method ' => 'return_something ' )));
167
167
}
168
168
169
- public function test_to_csv ()
170
- {
171
- $ book = Book::find (1 );
172
- $ this ->assert_equals ('1,1,2,"Ancient Art of Main Tanking",0,0 ' ,$ book ->to_csv ());
173
- }
174
-
175
- public function test_to_csv_only_header ()
176
- {
177
- $ book = Book::find (1 );
178
- $ this ->assert_equals ('book_id,author_id,secondary_author_id,name,numeric_test,special ' ,
179
- $ book ->to_csv (array ('only_header ' =>true ))
180
- );
181
- }
182
-
183
- public function test_to_csv_only_method ()
184
- {
185
- $ book = Book::find (1 );
186
- $ this ->assert_equals ('2,"Ancient Art of Main Tanking" ' ,
187
- $ book ->to_csv (array ('only ' =>array ('name ' ,'secondary_author_id ' )))
188
- );
189
- }
190
-
191
- public function test_to_csv_only_method_on_header ()
192
- {
193
- $ book = Book::find (1 );
194
- $ this ->assert_equals ('secondary_author_id,name ' ,
195
- $ book ->to_csv (array ('only ' =>array ('secondary_author_id ' ,'name ' ),
196
- 'only_header ' =>true ))
197
- );
198
- }
199
-
200
- public function test_to_csv_with_custom_delimiter ()
201
- {
202
- $ book = Book::find (1 );
203
- ActiveRecord \CsvSerializer::$ delimiter ='; ' ;
204
- $ this ->assert_equals ('1;1;2;"Ancient Art of Main Tanking";0;0 ' ,$ book ->to_csv ());
205
- }
206
-
207
- public function test_to_csv_with_custom_enclosure ()
208
- {
209
- $ book = Book::find (1 );
210
- ActiveRecord \CsvSerializer::$ delimiter =', ' ;
211
- ActiveRecord \CsvSerializer::$ enclosure ="' " ;
212
- $ this ->assert_equals ("1,1,2,'Ancient Art of Main Tanking',0,0 " ,$ book ->to_csv ());
213
- }
169
+ public function test_to_csv ()
170
+ {
171
+ $ book = Book::find (1 );
172
+ $ this ->assert_equals ('1,1,2,"Ancient Art of Main Tanking",0,0 ' ,$ book ->to_csv ());
173
+ }
174
+
175
+ public function test_to_csv_only_header ()
176
+ {
177
+ $ book = Book::find (1 );
178
+ $ this ->assert_equals ('book_id,author_id,secondary_author_id,name,numeric_test,special ' ,
179
+ $ book ->to_csv (array ('only_header ' =>true ))
180
+ );
181
+ }
182
+
183
+ public function test_to_csv_only_method ()
184
+ {
185
+ $ book = Book::find (1 );
186
+ $ this ->assert_equals ('2,"Ancient Art of Main Tanking" ' ,
187
+ $ book ->to_csv (array ('only ' =>array ('name ' ,'secondary_author_id ' )))
188
+ );
189
+ }
190
+
191
+ public function test_to_csv_only_method_on_header ()
192
+ {
193
+ $ book = Book::find (1 );
194
+ $ this ->assert_equals ('secondary_author_id,name ' ,
195
+ $ book ->to_csv (array ('only ' =>array ('secondary_author_id ' ,'name ' ),
196
+ 'only_header ' =>true ))
197
+ );
198
+ }
199
+
200
+ public function test_to_csv_with_custom_delimiter ()
201
+ {
202
+ $ book = Book::find (1 );
203
+ ActiveRecord \CsvSerializer::$ delimiter ='; ' ;
204
+ $ this ->assert_equals ('1;1;2;"Ancient Art of Main Tanking";0;0 ' ,$ book ->to_csv ());
205
+ }
206
+
207
+ public function test_to_csv_with_custom_enclosure ()
208
+ {
209
+ $ book = Book::find (1 );
210
+ ActiveRecord \CsvSerializer::$ delimiter =', ' ;
211
+ ActiveRecord \CsvSerializer::$ enclosure ="' " ;
212
+ $ this ->assert_equals ("1,1,2,'Ancient Art of Main Tanking',0,0 " ,$ book ->to_csv ());
213
+ }
214
214
}
0 commit comments