File tree Expand file tree Collapse file tree 3 files changed +64
-0
lines changed
Expand file tree Collapse file tree 3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change 44 "require" : {
55 "illuminate/support" : " ~5.0"
66 },
7+ "require-dev" : {
8+ "phpunit/phpunit" : " 4.5.*"
9+ },
710 "autoload" : {
811 "psr-4" : {
912 "Dowilcox\\ " : " src/"
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <phpunit backupGlobals =" false"
3+ backupStaticAttributes =" false"
4+ bootstrap =" vendor/autoload.php"
5+ colors =" true"
6+ convertErrorsToExceptions =" true"
7+ convertNoticesToExceptions =" true"
8+ convertWarningsToExceptions =" true"
9+ processIsolation =" false"
10+ stopOnFailure =" false"
11+ syntaxCheck =" false"
12+ >
13+ <testsuites >
14+ <testsuite name =" Package Test Suite" >
15+ <directory suffix =" .php" >./tests/</directory >
16+ </testsuite >
17+ </testsuites >
18+ </phpunit >
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ class JsVarTest extends PHPUnit_Framework_TestCase
4+ {
5+ protected $ jsVar ;
6+
7+ public function setup ()
8+ {
9+ $ this ->jsVar = new \Dowilcox \JsVar \JsVar ('tests ' );
10+ }
11+
12+ /** @test */
13+ public function it_outputs_array ()
14+ {
15+ $ this ->assertEquals ([], $ this ->jsVar ->toArray ());
16+ }
17+
18+ /** @test */
19+ public function it_outputs_json ()
20+ {
21+ $ this ->assertEquals ('[] ' , $ this ->jsVar ->toJson ());
22+ }
23+
24+ /** @test */
25+ public function it_adds_new_key_value_pair ()
26+ {
27+ $ this ->assertEquals (['user ' => 'test ' ], $ this ->jsVar ->add ('user ' , 'test ' )->toArray ());
28+ }
29+
30+ /** @test */
31+ public function it_dumps_to_javascript ()
32+ {
33+ $ this ->jsVar ->add ('user ' , 'test ' );
34+ $ this ->assertEquals ('window.tests = window.tests || {"user":"test"}; ' , $ this ->jsVar ->dump ());
35+ }
36+
37+ /** @test */
38+ public function it_removes_key_value_pair ()
39+ {
40+ $ this ->jsVar ->add ('user ' , 'test ' );
41+ $ this ->assertEquals ([], $ this ->jsVar ->remove ('user ' )->toArray ());
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments