diff --git a/includes/Checker/Checks/Enqueued_Resources_Check.php b/includes/Checker/Checks/Enqueued_Resources_Check.php new file mode 100644 index 000000000..07805aaaf --- /dev/null +++ b/includes/Checker/Checks/Enqueued_Resources_Check.php @@ -0,0 +1,49 @@ + 'php', + 'standard' => 'WordPress', + 'sniffs' => 'WordPress.WP.EnqueuedResources', + ); + } +} diff --git a/tests/phpunit/testdata/plugins/test-plugin-enqueued-resources-with-errors/load.php b/tests/phpunit/testdata/plugins/test-plugin-enqueued-resources-with-errors/load.php new file mode 100644 index 000000000..51dda69b9 --- /dev/null +++ b/tests/phpunit/testdata/plugins/test-plugin-enqueued-resources-with-errors/load.php @@ -0,0 +1,20 @@ + + + diff --git a/tests/phpunit/testdata/plugins/test-plugin-enqueued-resources-without-errors/load.php b/tests/phpunit/testdata/plugins/test-plugin-enqueued-resources-without-errors/load.php new file mode 100644 index 000000000..e2a579690 --- /dev/null +++ b/tests/phpunit/testdata/plugins/test-plugin-enqueued-resources-without-errors/load.php @@ -0,0 +1,30 @@ +run( $check_result ); + + $errors = $check_result->get_errors(); + + $this->assertNotEmpty( $errors ); + $this->assertArrayHasKey( 'load.php', $errors ); + $this->assertEquals( 2, $check_result->get_error_count() ); + } + + public function test_run_without_errors() { + $check = new Enqueued_Resources_Check(); + $check_context = new Check_Context( UNIT_TESTS_PLUGIN_DIR . 'test-plugin-enqueued-resources-without-errors/load.php' ); + $check_result = new Check_Result( $check_context ); + + $check->run( $check_result ); + + $errors = $check_result->get_errors(); + + $this->assertEmpty( $errors ); + $this->assertEquals( 0, $check_result->get_error_count() ); + } +}