diff options
author | Eric Barnes <eric@ericlbarnes.com> | 2012-07-29 06:15:40 +0200 |
---|---|---|
committer | Eric Barnes <eric@ericlbarnes.com> | 2012-07-29 06:15:40 +0200 |
commit | acedd2b1a37b22cb04b01038f21876ddfe38b83a (patch) | |
tree | b3b0a1a347abcbe9c2484072f8d859575654a9aa /tests/codeigniter/core | |
parent | 62ab8b24fc37a25eab9205c46321fa41729e5faf (diff) |
Adding a common stringify_attributes function for dealing with attributes through out various helpers.
Signed-off-by: Eric Barnes <eric@ericlbarnes.com>
Diffstat (limited to 'tests/codeigniter/core')
-rw-r--r-- | tests/codeigniter/core/Common_test.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php index f9bf6c27f..27d48efc2 100644 --- a/tests/codeigniter/core/Common_test.php +++ b/tests/codeigniter/core/Common_test.php @@ -10,4 +10,35 @@ class Common_test extends CI_TestCase { $this->assertEquals(FALSE, is_php('9999.9.9')); } + // ------------------------------------------------------------------------ + + public function test_stringify_attributes() + { + $this->assertEquals(' class="foo" id="bar"', _stringify_attributes(array('class' => 'foo', 'id' => 'bar'))); + + $atts = new Stdclass; + $atts->class = 'foo'; + $atts->id = 'bar'; + $this->assertEquals(' class="foo" id="bar"', _stringify_attributes($atts)); + + $atts = new Stdclass; + $this->assertEquals('', _stringify_attributes($atts)); + + $this->assertEquals(' class="foo" id="bar"', _stringify_attributes('class="foo" id="bar"')); + + $this->assertEquals('', _stringify_attributes(array())); + } + + // ------------------------------------------------------------------------ + + public function test_stringify_js_attributes() + { + $this->assertEquals('width=800,height=600', _stringify_attributes(array('width' => '800', 'height' => '600'), TRUE)); + + $atts = new Stdclass; + $atts->width = 800; + $atts->height = 600; + $this->assertEquals('width=800,height=600', _stringify_attributes($atts, TRUE)); + } + }
\ No newline at end of file |