mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
59efd280ad
Standardise template locations Move CMSSettingsController class to SiteConfig module Fix CMSMenu behaviour for namespaced admin sections Split classes into one per file Manual fixes and cleanup
47 lines
1.3 KiB
PHP
47 lines
1.3 KiB
PHP
<?php
|
|
|
|
use SilverStripe\Admin\CMSMenuItem;
|
|
/**
|
|
* @package framework
|
|
* @subpackage tests
|
|
*/
|
|
class CMSMenuItemTest extends SapphireTest {
|
|
|
|
public function testAttributes() {
|
|
$menuItem = new CMSMenuItem('Foo', 'foo');
|
|
$exampleAttributes = array('title' => 'foo bar', 'disabled' => true, 'data-foo' => '<something>');
|
|
|
|
$this->assertEquals(
|
|
'title="foo bar" disabled="disabled" data-foo="<something>"',
|
|
(string)$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(
|
|
'',
|
|
(string)$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>"',
|
|
(string)$menuItem->getAttributesHTML(),
|
|
'Attributes appear correctly when using setAttributes()'
|
|
);
|
|
$this->assertEquals(
|
|
'title="foo bar" disabled="disabled"',
|
|
(string)$menuItem->getAttributesHTML('data-foo'),
|
|
'getAttributesHTML() ignores a string argument and falls back to class property'
|
|
);
|
|
}
|
|
|
|
}
|