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

More tests.

parent 1adcc697
No related branches found
No related tags found
1 merge request!3Feature/more tests
Pipeline #6865 passed with warnings
...@@ -72,8 +72,10 @@ class AjaxHandler implements HookablePluginDependant ...@@ -72,8 +72,10 @@ class AjaxHandler implements HookablePluginDependant
); );
do_action('wpdesk_notice_dismissed_notice', $noticeName); do_action('wpdesk_notice_dismissed_notice', $noticeName);
} }
if (defined('DOING_AJAX') && DOING_AJAX) {
die(); die();
} }
}
} }
<?php <?php
use \WPDesk\Notice\AjaxHandler; use \WPDesk\Notice\AjaxHandler;
use \WPDesk\Notice\PermanentDismissibleNotice;
class TestAjaxHandler extends WP_UnitTestCase class TestAjaxHandler extends WP_UnitTestCase
{ {
const ASSETS_URL = 'http://test.com/test/assetes/'; const ASSETS_URL = 'http://test.com/test/assetes/';
const NOTICE_NAME = 'test_notice_name';
const WP_DEFAULT_PRIORITY = 10; const WP_DEFAULT_PRIORITY = 10;
public function testHooks() public function testHooks()
...@@ -38,4 +40,16 @@ class TestAjaxHandler extends WP_UnitTestCase ...@@ -38,4 +40,16 @@ class TestAjaxHandler extends WP_UnitTestCase
); );
} }
public function testProcessAjaxNoticeDismiss() {
$_POST[AjaxHandler::POST_FIELD_NOTICE_NAME] = self::NOTICE_NAME;
$ajaxHandler = new AjaxHandler(self::ASSETS_URL);
$ajaxHandler->processAjaxNoticeDismiss();
$this->assertEquals(
PermanentDismissibleNotice::OPTION_VALUE_DISMISSED,
get_option(PermanentDismissibleNotice::OPTION_NAME_PREFIX . self::NOTICE_NAME)
);
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment