Skip to content
Snippets Groups Projects
Commit 4ce2f6fb authored by Grzegorz Rola's avatar Grzegorz Rola
Browse files

addAttribute method.

parent 9a575dd7
No related branches found
No related tags found
1 merge request!9Feature/wpdesk notices action
Pipeline #8603 passed
This commit is part of merge request !9. Comments created here will be created in the context of that merge request.
......@@ -167,6 +167,9 @@ class Notice
}
}
/**
* Remove action.
*/
protected function removeAction()
{
if ($this->actionAdded) {
......@@ -180,6 +183,17 @@ class Notice
}
}
/**
* Add attribute.
*
* @param string $name Name
* @param string $value Value.
*/
public function addAttribute($name, $value)
{
$this->attributes[ $name ] = $value;
}
/**
* Get notice class.
*
......
......@@ -118,4 +118,26 @@ class TestNotice extends WP_UnitTestCase
$this->assertEquals(20, $notice->getPriority());
}
public function testAddAttribute()
{
$notice = new Notice('test', Notice::NOTICE_TYPE_WARNING);
$notice->addAttribute('id', 'test_id');
$this->expectOutputString('<div class="notice notice-warning" id="test_id"><p>test</p></div>');
$notice->showNotice();
}
public function testAddAttributeClass()
{
$notice = new Notice('test', Notice::NOTICE_TYPE_WARNING);
$notice->addAttribute('class', 'test-class');
$this->expectOutputString('<div class="notice notice-warning test-class"><p>test</p></div>');
$notice->showNotice();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment