1111use frictionlessdata \tableschema \InferSchema ;
1212use frictionlessdata \tableschema \Table ;
1313use frictionlessdata \tableschema \DataSources \CsvDataSource ;
14- use frictionlessdata \datapackage \Resources \DefaultResource ;
15- use frictionlessdata \datapackage \Resources \TabularResource ;
1614
1715class DatapackageTest extends TestCase
1816{
@@ -271,7 +269,7 @@ public function testDatapackageResources()
271269
272270 // add a resource
273271 $ this ->assertCount (1 , $ datapackage ->resources ());
274- $ datapackage ->resource (" new-resource " , [
272+ $ datapackage ->resource (' new-resource ' , [
275273 'path ' => ['tests/fixtures/foo.txt ' , 'tests/fixtures/baz.txt ' ],
276274 ]);
277275 $ this ->assertCount (2 , $ datapackage ->resources ());
@@ -329,11 +327,11 @@ public function testCreateEditDatapackageDescriptor()
329327 // create static method allows to create a new datapackage or resource without validation
330328 // with shortcut arguments for common use-cases
331329 $ package = Package::create ([
332- " name " => 'my-datapackage-name ' ,
333- " resources " => [
334- [" name " => " my-default-resource " ],
335- [" name " => " my-tabular-resource " , " profile " => " tabular-data-resource " ]
336- ]
330+ ' name ' => 'my-datapackage-name ' ,
331+ ' resources ' => [
332+ [' name ' => ' my-default-resource ' ],
333+ [' name ' => ' my-tabular-resource ' , ' profile ' => ' tabular-data-resource ' ],
334+ ],
337335 ]);
338336 // the tabular resource is missing schema, but it doesn't fail
339337 // when creating a datapackage or resource with the create method it doesn't validate
@@ -345,17 +343,17 @@ public function testCreateEditDatapackageDescriptor()
345343 ],
346344 (object ) [
347345 'name ' => 'my-tabular-resource ' ,
348- " profile " => " tabular-data-resource "
346+ ' profile ' => ' tabular-data-resource ' ,
349347 ],
350348 ],
351349 ], $ package ->descriptor ());
352350 // you can now modify the descriptor further by editing the descriptor directly
353- $ package ->descriptor ()->resources [1 ]->name = " my-renamed-tabular-resource " ;
351+ $ package ->descriptor ()->resources [1 ]->name = ' my-renamed-tabular-resource ' ;
354352 $ package ->descriptor ()->resources [1 ]->schema = [
355- " fields " => [
356- [" name " => " id " , " type " => " integer " ],
357- [" name " => " name " , " type " => " string " ]
358- ]
353+ ' fields ' => [
354+ [' name ' => ' id ' , ' type ' => ' integer ' ],
355+ [' name ' => ' name ' , ' type ' => ' string ' ],
356+ ],
359357 ];
360358 // when you are done you can revalidate
361359 try {
@@ -380,7 +378,7 @@ public function testCreateEditDatapackageDescriptor()
380378
381379 $ defaultSecondPath = tempnam (sys_get_temp_dir (), 'datapackage-php-tests- ' ).'.csv ' ;
382380 $ package ->resource ('my-default-resource ' )->descriptor ()->path [] = $ defaultSecondPath ;
383- file_put_contents ($ defaultSecondPath , " BAHHH " );
381+ file_put_contents ($ defaultSecondPath , ' BAHHH ' );
384382
385383 $ tabularDataFilename = tempnam (sys_get_temp_dir (), 'datapackage-php-tests- ' ).'.csv ' ;
386384 $ package ->resource ('my-renamed-tabular-resource ' )->descriptor ()->path [] = $ tabularDataFilename ;
@@ -401,7 +399,7 @@ public function testCreateEditDatapackageDescriptor()
401399 $ this ->assertContains ('Failed to open tabular data source ' , $ e ->getMessage ());
402400 }
403401 }
404- };
402+ }
405403
406404 // write data to the new simple data source
407405 // you have to do this yourself, we don't support writing data stream at the moment
@@ -412,7 +410,7 @@ public function testCreateEditDatapackageDescriptor()
412410 $ i = 0 ;
413411 foreach ($ package ->resource ('my-default-resource ' ) as $ row ) {
414412 if ($ i == 0 ) {
415- $ this ->assertEquals (" foo " , $ row );
413+ $ this ->assertEquals (' foo ' , $ row );
416414 } elseif ($ i == 1 ) {
417415 $ this ->assertEquals ("testing 改善 \n" , $ row );
418416 } elseif ($ i == 2 ) {
@@ -437,78 +435,78 @@ public function testCreateEditDatapackageDescriptor()
437435 'name ' => 'my-renamed-tabular-resource ' ,
438436 'path ' => [$ tabularDataFilename ],
439437 'profile ' => 'tabular-data-resource ' ,
440- 'schema ' => (object )[
441- " fields " => [
442- (object )[ " name " => " id " , " type " => " integer " ],
443- (object )[ " name " => " name " , " type " => " string " ]
444- ]
445- ]
438+ 'schema ' => (object ) [
439+ ' fields ' => [
440+ (object ) [ ' name ' => ' id ' , ' type ' => ' integer ' ],
441+ (object ) [ ' name ' => ' name ' , ' type ' => ' string ' ],
442+ ],
443+ ],
446444 ],
447445 ],
448446 ], json_decode (file_get_contents ($ filename )));
449447
450448 file_put_contents ($ tabularDataFilename , "id,name \n1, \"one \"\n2, \"two \"\n3, \"three \"" );
451449 $ this ->assertEquals ([
452- [" id " => 1 , " name " => " one " ],
453- [" id " => 2 , " name " => " two " ],
454- [" id " => 3 , " name " => " three " ]
455- ], $ package ->resource (" my-renamed-tabular-resource " )->read ());
450+ [' id ' => 1 , ' name ' => ' one ' ],
451+ [' id ' => 2 , ' name ' => ' two ' ],
452+ [' id ' => 3 , ' name ' => ' three ' ],
453+ ], $ package ->resource (' my-renamed-tabular-resource ' )->read ());
456454 }
457455
458456 public function testStringPath ()
459457 {
460- $ package = Package::create ([" resources " => [
461- [" name " => " _ " , " path " => dirname (__FILE__ ).'/fixtures/foo.txt ' ]
458+ $ package = Package::create ([' resources ' => [
459+ [' name ' => ' _ ' , ' path ' => dirname (__FILE__ ).'/fixtures/foo.txt ' ],
462460 ]]);
463- $ this ->assertEquals ([" foo " ], $ package ->resource (" _ " )->read ());
461+ $ this ->assertEquals ([' foo ' ], $ package ->resource (' _ ' )->read ());
464462 }
465463
466464 public function testInlineDataRowArrays ()
467465 {
468466 $ resource = Resource::create ([
469- "name " => "_ " ,
470- "profile " => "tabular-data-resource " ,
471- "schema " => [
472- "fields " => [
473- ["name " => "id " , "type " => "integer " ],
474- ["name " => "name " , "type " => "string " ]
475- ]
467+ 'name ' => '_ ' ,
468+ 'profile ' => 'tabular-data-resource ' ,
469+ 'schema ' => [
470+ 'fields ' => [
471+ ['name ' => 'id ' , 'type ' => 'integer ' ],
472+ ['name ' => 'name ' , 'type ' => 'string ' ],
473+ ],
474+ ],
475+ 'data ' => [
476+ ['id ' , 'name ' ],
477+ [1 , 'one ' ],
478+ [2 , 'two ' ],
479+ [3 , 'three ' ],
476480 ],
477- "data " => [
478- ["id " , "name " ],
479- [1 , "one " ],
480- [2 , "two " ],
481- [3 , "three " ]
482- ]
483481 ]);
484482 $ this ->assertEquals ([
485- [" id " => 1 , " name " => " one " ],
486- [" id " => 2 , " name " => " two " ],
487- [" id " => 3 , " name " => " three " ]
483+ [' id ' => 1 , ' name ' => ' one ' ],
484+ [' id ' => 2 , ' name ' => ' two ' ],
485+ [' id ' => 3 , ' name ' => ' three ' ],
488486 ], $ resource ->read ());
489487 }
490488
491489 public function testInlineDataRowObjects ()
492490 {
493491 $ resource = Resource::create ([
494- "name " => "_ " ,
495- "profile " => "tabular-data-resource " ,
496- "schema " => [
497- "fields " => [
498- ["name " => "id " , "type " => "integer " ],
499- ["name " => "name " , "type " => "string " ]
500- ]
492+ 'name ' => '_ ' ,
493+ 'profile ' => 'tabular-data-resource ' ,
494+ 'schema ' => [
495+ 'fields ' => [
496+ ['name ' => 'id ' , 'type ' => 'integer ' ],
497+ ['name ' => 'name ' , 'type ' => 'string ' ],
498+ ],
499+ ],
500+ 'data ' => [
501+ ['id ' => 1 , 'name ' => 'one ' ],
502+ ['id ' => 2 , 'name ' => 'two ' ],
503+ ['id ' => 3 , 'name ' => 'three ' ],
501504 ],
502- "data " => [
503- ["id " => 1 , "name " => "one " ],
504- ["id " => 2 , "name " => "two " ],
505- ["id " => 3 , "name " => "three " ]
506- ]
507505 ]);
508506 $ this ->assertEquals ([
509- [" id " => 1 , " name " => " one " ],
510- [" id " => 2 , " name " => " two " ],
511- [" id " => 3 , " name " => " three " ]
507+ [' id ' => 1 , ' name ' => ' one ' ],
508+ [' id ' => 2 , ' name ' => ' two ' ],
509+ [' id ' => 3 , ' name ' => ' three ' ],
512510 ], $ resource ->read ());
513511 }
514512
0 commit comments