From c34167b0ec1bb848457f477be9a1ad8074dcdf55 Mon Sep 17 00:00:00 2001 From: Loz Calver Date: Wed, 9 Oct 2013 10:43:53 +0100 Subject: [PATCH] Unit test coverage for CMSMenuItem --- admin/tests/CMSMenuItemTest.php | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 admin/tests/CMSMenuItemTest.php diff --git a/admin/tests/CMSMenuItemTest.php b/admin/tests/CMSMenuItemTest.php new file mode 100644 index 000000000..d6f61b173 --- /dev/null +++ b/admin/tests/CMSMenuItemTest.php @@ -0,0 +1,44 @@ + 'foo bar', 'disabled' => true, 'data-foo' => ''); + + $this->assertEquals( + 'title="foo bar" disabled="disabled" data-foo="<something>"', + $menuItem->getAttributesHTML($exampleAttributes), + 'Attributes appear correctly when passed as an argument' + ); + + $emptyAttributes = array('empty' => ''); + $this->assertEquals( + '', + $menuItem->getAttributesHTML($emptyAttributes), + 'No attributes are output when argument values are empty' + ); + $this->assertEquals( + '', + $menuItem->getAttributesHTML('some string'), + 'getAttributesHTML() ignores a string argument' + ); + + // Set attributes as class property + $menuItem->setAttributes($exampleAttributes); + $this->assertEquals( + 'title="foo bar" disabled="disabled" data-foo="<something>"', + $menuItem->getAttributesHTML(), + 'Attributes appear correctly when using setAttributes()' + ); + $this->assertEquals( + 'title="foo bar" disabled="disabled" data-foo="<something>"', + $menuItem->getAttributesHTML('foo bar'), + 'getAttributesHTML() ignores a string argument and falls back to class property' + ); + } + +} \ No newline at end of file