forked from studiofrenetic/laravel-formatter
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from SoapBox/F-Adding-Test-Cases
Updating travis/composer and adding basic test cases.
- Loading branch information
Showing
8 changed files
with
93 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
<?php | ||
|
||
return array( | ||
'csv' => array( | ||
'delimiter' => ',', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
use SoapBox\Formatter\Formatter; | ||
//use Mockery as m; | ||
|
||
class FormatterTest extends Orchestra\Testbench\TestCase { | ||
|
||
public function setUp() { | ||
parent::setUp(); | ||
|
||
} | ||
/** | ||
* A basic functional test for JSON to Array conversion | ||
* | ||
* @return void | ||
*/ | ||
public function testJsonToArray() { | ||
$data = '{"foo":"bar","bar":"foo"}'; | ||
$result = Formatter::make($data, 'json')->to_array(); | ||
$expected = array('foo'=>'bar', 'bar'=>'foo'); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** | ||
* A basic functional test for Array to JSON conversion | ||
* | ||
* @return void | ||
*/ | ||
public function testArrayToJson() { | ||
$data = array('foo'=>'bar', 'bar'=>'foo'); | ||
$result = Formatter::make($data)->to_json(); | ||
$expected = '{"foo":"bar","bar":"foo"}'; | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** | ||
* A basic functional test for testJSONToXMLToArrayToJsonToArray data to array | ||
* | ||
* @return void | ||
*/ | ||
public function testJSONToXMLToArrayToJsonToArray() { | ||
$data = '{"foo":"bar","bar":"foo"}'; | ||
$result = Formatter::make($data, 'json')->to_xml(); | ||
$result = Formatter::make($result, 'xml')->to_array(); | ||
$result = Formatter::make($result, 'array')->to_json(); | ||
$result = Formatter::make($result, 'json')->to_array(); | ||
$expected = array('foo'=>'bar', 'bar'=>'foo'); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
/** | ||
* A basic functional test for CSV data to array | ||
* | ||
* @return void | ||
*/ | ||
public function testCSVToArray() { | ||
$data = 'foo,bar,bing,bam,boom'; | ||
$result = Formatter::make($data, 'csv')->to_array(); | ||
$expected = array('foo','bar','bing','bam','boom'); | ||
$this->assertEquals($expected, $result); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
|
||
require dirname(__DIR__) . '/src/SoapBox/Formatter/Formatter.php'; |