Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
14 additions
and
14 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
18 changes: 9 additions & 9 deletions
18
tests/unit/JsUtilsTest.php → tests/unit/JavascriptUtilsTest.php
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,35 +1,35 @@ | ||
<?php | ||
use PHPMV\js\JsUtils; | ||
use PHPMV\js\JavascriptUtils; | ||
|
||
include_once dirname(__FILE__) . '/../files/classes/TestClass1.php'; | ||
include_once dirname(__FILE__) . '/../files/classes/TestClass2.php'; | ||
|
||
/** | ||
* JsUtils test case. | ||
* JavascriptUtils test case. | ||
*/ | ||
class JsUtilsTest extends \Codeception\Test\Unit { | ||
class JavascriptUtilsTest extends \Codeception\Test\Unit { | ||
|
||
/** | ||
* Tests JsUtils::objectToJSON() | ||
* Tests JavascriptUtils::objectToJSON() | ||
*/ | ||
public function testObjectToJSON() { | ||
$c1 = new TestClass1(); | ||
$c1->id = 11; | ||
$c1->name = 'Foo'; | ||
$this->assertEquals(json_decode('{"id":11,"name":"Foo"}'), json_decode(JsUtils::objectToJSON($c1))); | ||
$this->assertEquals(json_decode('{"id":11,"name":"Foo"}'), json_decode(JavascriptUtils::objectToJSON($c1))); | ||
|
||
$c2 = new TestClass2(11, "Bar"); | ||
$this->assertEquals(json_decode('{"id":11,"name":"Bar"}'), json_decode(JsUtils::objectToJSON($c2))); | ||
$this->assertEquals(json_decode('{"id":11,"name":"Bar"}'), json_decode(JavascriptUtils::objectToJSON($c2))); | ||
} | ||
|
||
/** | ||
* Tests JsUtils::wrapScript() | ||
* Tests JavascriptUtils::wrapScript() | ||
*/ | ||
public function testWrapScript() { | ||
$s1 = "alert('test');"; | ||
$this->assertEquals("<script>alert('test');</script>", JsUtils::wrapScript($s1)); | ||
$this->assertEquals("<script>alert('test');</script>", JavascriptUtils::wrapScript($s1)); | ||
$s2 = "<script>alert('test');</script>"; | ||
$this->assertEquals($s2, JsUtils::wrapScript($s2)); | ||
$this->assertEquals($s2, JavascriptUtils::wrapScript($s2)); | ||
} | ||
} | ||
|