From 89330e0767424a6af5fe7dc6c384bdd651819b3a Mon Sep 17 00:00:00 2001
From: Grzegorz Rola <grola@seostudio.pl>
Date: Fri, 3 Mar 2023 09:57:43 +0100
Subject: [PATCH] feature(ajax): added nonce

---
 tests/codeception/tests/integration.suite.yml     | 15 +++++++++++++++
 .../{TestAjaxHandler.php => AjaxHandlerTest.php}  |  4 ++--
 2 files changed, 17 insertions(+), 2 deletions(-)
 rename tests/codeception/tests/integration/{TestAjaxHandler.php => AjaxHandlerTest.php} (80%)

diff --git a/tests/codeception/tests/integration.suite.yml b/tests/codeception/tests/integration.suite.yml
index 50f5eaa..ee87e7a 100644
--- a/tests/codeception/tests/integration.suite.yml
+++ b/tests/codeception/tests/integration.suite.yml
@@ -4,8 +4,23 @@
 
 modules:
     enabled:
+        - WPDb
         - WPLoader
     config:
+        WPDb:
+            dsn: 'mysql:host=%TEST_SITE_DB_HOST%;dbname=%TEST_SITE_DB_NAME%'
+            user: '%TEST_SITE_DB_USER%'
+            password: '%TEST_SITE_DB_PASSWORD%'
+            dump: 'tests/codeception/tests/_data/db.sql'
+            #import the dump before the tests; this means the test site database will be repopulated before the tests.
+            populate: false
+            # re-import the dump between tests; this means the test site database will be repopulated between the tests.
+            cleanup: false
+            waitlock: 10
+            url: '%TEST_SITE_WP_URL%'
+            originalUrl: '%TEST_SITE_WP_URL%'
+            urlReplacement: true #replace the hardcoded dump URL with the one above
+            tablePrefix: '%TEST_SITE_TABLE_PREFIX%'
         WPLoader:
             multisite: false
             wpRootFolder: '%WP_ROOT_FOLDER%'
diff --git a/tests/codeception/tests/integration/TestAjaxHandler.php b/tests/codeception/tests/integration/AjaxHandlerTest.php
similarity index 80%
rename from tests/codeception/tests/integration/TestAjaxHandler.php
rename to tests/codeception/tests/integration/AjaxHandlerTest.php
index eebf7cf..c4e402e 100644
--- a/tests/codeception/tests/integration/TestAjaxHandler.php
+++ b/tests/codeception/tests/integration/AjaxHandlerTest.php
@@ -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';
@@ -68,7 +68,7 @@ class TestAjaxHandler extends WPTestCase {
 		$ajaxHandler->hooks();
 
 		$this->expectOutputString( '<script type="text/javascript">
-' . file_get_contents( __DIR__ . '/../../assets/js/notice.js' ) . '
+jQuery(document).on("click",".notice-dismiss",function(){var a=jQuery(this).closest("div.notice").data("notice-name");var b=jQuery(this).closest("div.notice").data("source");if(""!==a){jQuery.ajax({url:ajaxurl,type:"post",data:{action:"wpdesk_notice_dismiss",notice_name:a,source:b},success:function(c){}})}});jQuery(document).on("click",".notice-dismiss-link",function(){jQuery(this).closest("div.notice").data("source",jQuery(this).data("source"));jQuery(this).closest("div.notice").find(".notice-dismiss").click()});
 </script>
 '
 		);
-- 
GitLab