1
1
<?php
2
2
3
- use SoapBox \Formatter \LaravelHtmlMinifyCompiler ;
3
+ use SoapBox \Formatter \Formatter ;
4
+ //use Mockery as m;
4
5
6
+ class FormatterTest extends Orchestra \Testbench \TestCase {
5
7
6
- class FormatterTest extends PHPUnit_Framework_TestCase {
8
+ public function setUp () {
9
+ parent ::setUp ();
10
+
11
+ //$app = m::mock('AppMock');
12
+ //$app->shouldReceive('instance')->once()->andReturn($app);
13
+
14
+ //Illuminate\Support\Facades\Facade::setFacadeApplication($app);
15
+ //Illuminate\Support\Facades\Config::swap($config = m::mock('ConfigMock'));
16
+ //Illuminate\Support\Facades\Lang::swap($lang = m::mock('ConfigLang'));
17
+
18
+ //$config->shouldReceive('get')->once()->with('logviewer::log_dirs')->andReturn(array('app' => 'app/storage/logs'));
19
+ //$this->logviewer = new Logviewer('app', 'cgi-fcgi', '2013-06-01');
20
+ }
21
+ /**
22
+ * A basic functional test for JSON to Array conversion
23
+ *
24
+ * @return void
25
+ */
26
+ public function testJsonToArray () {
27
+ $ data = '{"foo":"bar","bar":"foo"} ' ;
28
+ $ result = Formatter::make ($ data , 'json ' )->to_array ();
29
+ $ expected = array ('foo ' =>'bar ' , 'bar ' =>'foo ' );
30
+ $ this ->assertEquals ($ expected , $ result );
31
+ }
7
32
8
33
/**
9
- * A basic functional test example.
34
+ * A basic functional test for Array to JSON conversion
10
35
*
11
36
* @return void
12
37
*/
13
- public function testBasicExample () {
14
- $ this ->assertTrue (true );
38
+ public function testArrayToJson () {
39
+ $ data = array ('foo ' =>'bar ' , 'bar ' =>'foo ' );
40
+
41
+ $ result = Formatter::make ($ data )->to_json ();
42
+ $ expected = '{"foo":"bar","bar":"foo"} ' ;
43
+ $ this ->assertEquals ($ expected , $ result );
15
44
}
16
45
17
- /*
18
- public function testFormatter() {
19
- //$formatted = SoapBox\Formatter::make('hello')=>array();
20
- //var_dump($formatted);
46
+ /**
47
+ * A basic functional test for testJSONToXMLToArrayToJsonToArray data to array
48
+ *
49
+ * @return void
50
+ */
51
+ public function testJSONToXMLToArrayToJsonToArray () {
52
+ $ data = '{"foo":"bar","bar":"foo"} ' ;
53
+
54
+ $ result = Formatter::make ($ data , 'json ' )->to_xml ();
55
+ $ result = Formatter::make ($ result , 'xml ' )->to_array ();
56
+ $ result = Formatter::make ($ result , 'array ' )->to_json ();
57
+ $ result = Formatter::make ($ result , 'json ' )->to_array ();
58
+
59
+ $ expected = array ('foo ' =>'bar ' , 'bar ' =>'foo ' );
60
+
61
+ $ this ->assertEquals ($ expected , $ result );
62
+ }
21
63
22
- //$expected = array('hello');
23
- //$this->assertEquals($expected, $formatted);
64
+ /**
65
+ * A basic functional test for CSV data to array
66
+ *
67
+ * @return void
68
+ */
69
+ public function testCSVToArray () {
70
+ $ data = "foo,bar,bing,bam,boom " ;
71
+ $ result = Formatter::make ($ data , 'csv ' )->to_array ();
72
+ $ expected = array ('foo ' =>'bar ' , 'bar ' =>'foo ' );
73
+ var_dump ($ result );
74
+ var_dump ($ expected );
75
+ die ('dead ' );
76
+ $ this ->assertEquals ($ expected , $ result );
24
77
}
25
- */
26
78
79
+ /**
80
+ * A basic functional test for CSV data to array
81
+ *
82
+ * @return void
83
+ */
84
+ public function testArrayToCSV () {
85
+ $ expected = array ('foo ' =>'bar ' , 'bar ' =>'foo ' );
86
+ $ result = Formatter::make ($ data , 'array ' )->to_csv ();
87
+ var_dump ($ result );
88
+
89
+ $ expected = "foo,bar,bing,bam,boom " ;
90
+ $ this ->assertEquals ($ expected , $ result );
91
+ }
27
92
}
0 commit comments