Skip to content
Snippets Groups Projects

feature(ajax): added nonce

Merged Grzegorz Rola requested to merge feature/dismiss-nonce into master
All threads resolved!

Files

@@ -6,7 +6,7 @@ use Codeception\TestCase\WPTestCase;
use \WPDesk\Notice\AjaxHandler;
use \WPDesk\Notice\PermanentDismissibleNotice;
class TestAjaxHandler extends WPTestCase {
class AjaxHandlerTest extends WPTestCase {
const ASSETS_URL = 'http://test.com/test/assetes/';
const NOTICE_NAME = 'test_notice_name';
@@ -67,9 +67,10 @@ class TestAjaxHandler extends WPTestCase {
$ajaxHandler = new AjaxHandler();
$ajaxHandler->hooks();
$this->expectOutputString( '<script type="text/javascript">
' . file_get_contents( __DIR__ . '/../../assets/js/notice.js' ) . '
</script>
$this->expectOutputString( '<script type="text/javascript">'
. "\n "
. file_get_contents( __DIR__ . '/../../../../assets/js/notice.js' )
. '</script>
'
);
@@ -78,6 +79,7 @@ class TestAjaxHandler extends WPTestCase {
public function testProcessAjaxNoticeDismiss() {
$_POST[ AjaxHandler::POST_FIELD_NOTICE_NAME ] = self::NOTICE_NAME;
$_POST[ AjaxHandler::POST_FIELD_SECURITY ] = wp_create_nonce( PermanentDismissibleNotice::OPTION_NAME_PREFIX . sanitize_text_field( self::NOTICE_NAME ) );
$ajaxHandler = new AjaxHandler( self::ASSETS_URL );
$ajaxHandler->processAjaxNoticeDismiss();
Loading