diff --git a/composer.json b/composer.json
index 9be7448..a64abda 100644
--- a/composer.json
+++ b/composer.json
@@ -33,7 +33,8 @@
"phpcompatibility/php-compatibility": "*",
"wp-coding-standards/wpcs": "*",
"phpunit/phpunit": "^8.5",
- "yoast/phpunit-polyfills": "^2.0"
+ "yoast/phpunit-polyfills": "^2.0",
+ "wp-phpunit/wp-phpunit": "^6.7"
},
"require": {
"php": ">=7.4"
diff --git a/package.json b/package.json
index 8770a98..f72b645 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,8 @@
"format": "wp-scripts format",
"wp-env": "wp-env",
"release": "composer run build && npm run build && npm run plugin-zip",
- "test:unit": "./vendor/bin/phpunit"
+ "test:unit": "./vendor/bin/phpunit --configuration ./tests/unit/phpunit.xml",
+ "test:integration": "wp-env run tests-cli --env-cwd=wp-content/plugins/advanced-query-loop ./vendor/bin/phpunit --configuration ./tests/integration/phpunit.xml"
},
"files": [
"build",
diff --git a/phpcs.xml b/phpcs.xml
index 484a7f1..eaef45a 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -39,6 +39,8 @@
+
+
@@ -64,6 +66,7 @@
+
diff --git a/tests/integration/bootstrap.php b/tests/integration/bootstrap.php
new file mode 100644
index 0000000..ea42c07
--- /dev/null
+++ b/tests/integration/bootstrap.php
@@ -0,0 +1,38 @@
+
+
+
+ ./tests/
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tests/integration/tests/Filter_Tests.php b/tests/integration/tests/Filter_Tests.php
new file mode 100644
index 0000000..c9ee3b4
--- /dev/null
+++ b/tests/integration/tests/Filter_Tests.php
@@ -0,0 +1,82 @@
+ [
+ [
+ 'taxonomy' => 'category',
+ 'terms' => [ 1 ],
+ 'include_children' => true,
+ 'operator' => 'IN',
+ ],
+ [
+ 'taxonomy' => 'recipe_category',
+ 'field' => 'slug',
+ 'terms' => 'pasta',
+ 'operator' => 'NOT IN',
+ 'include_children' => false,
+ ],
+ ],
+ ];
+
+ $default_params_from_block = [];
+
+ $custom_params_from_aql = [
+ 'tax_query' => [
+ 'queries' => [
+ [
+ 'id' => '9aa9887e-e61b-42e0-bc5d-3b8c60337a3b',
+ 'taxonomy' => 'category',
+ 'terms' => [ 'Uncategorized' ],
+ 'include_children' => true,
+ 'operator' => 'IN',
+ ],
+ ],
+ ],
+ ];
+
+ $qpg = new Query_Params_Generator( $default_params_from_block, $custom_params_from_aql );
+
+ add_filter(
+ 'aql_query_vars',
+ function ( $query_args, $default_params, $context ) {
+ $query_args['tax_query'][] = array(
+ 'taxonomy' => 'recipe_category',
+ 'field' => 'slug',
+ 'terms' => 'pasta',
+ 'operator' => 'NOT IN',
+ 'include_children' => false,
+ );
+ return $query_args;
+ },
+ 10,
+ 3
+ );
+
+ $qpg->process_all();
+ $query_args = $qpg->get_query_args();
+ $filtered_query_args = \apply_filters(
+ 'aql_query_vars',
+ $query_args,
+ $default_params_from_block,
+ false
+ );
+ // Assertions
+ $this->assertSame( $expected_query_args, array_merge( $default_params_from_block, $filtered_query_args ) );
+ }
+
+ public function test_tax_query_add_items_to_default_tax_query() {}
+
+}
diff --git a/phpunit.xml b/tests/unit/phpunit.xml
similarity index 89%
rename from phpunit.xml
rename to tests/unit/phpunit.xml
index 07ee568..e1a25e0 100644
--- a/phpunit.xml
+++ b/tests/unit/phpunit.xml
@@ -1,7 +1,7 @@
- tests/unit
+ tests
diff --git a/tests/unit/Date_Query_Tests.php b/tests/unit/tests/Date_Query_Tests.php
similarity index 100%
rename from tests/unit/Date_Query_Tests.php
rename to tests/unit/tests/Date_Query_Tests.php
diff --git a/tests/unit/Exclude_Current_Tests.php b/tests/unit/tests/Exclude_Current_Tests.php
similarity index 100%
rename from tests/unit/Exclude_Current_Tests.php
rename to tests/unit/tests/Exclude_Current_Tests.php
diff --git a/tests/unit/Multiple_Post_Types_Tests.php b/tests/unit/tests/Multiple_Post_Types_Tests.php
similarity index 100%
rename from tests/unit/Multiple_Post_Types_Tests.php
rename to tests/unit/tests/Multiple_Post_Types_Tests.php
diff --git a/tests/unit/Query_Params_Generator_Tests.php b/tests/unit/tests/Query_Params_Generator_Tests.php
similarity index 100%
rename from tests/unit/Query_Params_Generator_Tests.php
rename to tests/unit/tests/Query_Params_Generator_Tests.php