@@ -32,10 +32,22 @@ public function test_passing_fixtures( string $file ): void {
3232 * Test that fixtures fail.
3333 *
3434 * @param string $file The file to test.
35+ * @param string $expectation The expectations file for this test.
3536 */
3637 #[DataProvider( 'failing_fixture_data_provider ' )]
37- public function test_failing_fixtures ( string $ file ): void {
38- $ this ->process_phpcs_output ( $ this ->run_phpcs ( $ file ), expect_to_fail: true );
38+ public function test_failing_fixtures ( string $ file , ?string $ expectation = null ): void {
39+
40+ $ expectations = [];
41+
42+ if ( ! empty ( $ expectation ) && file_exists ( $ expectation ) ) {
43+ $ expectations = include $ expectation ;
44+ }
45+
46+ $ this ->process_phpcs_output (
47+ $ this ->run_phpcs ( $ file ),
48+ ignored_errors: $ expectations ,
49+ expect_to_fail: true
50+ );
3951 }
4052
4153 /**
@@ -53,7 +65,19 @@ public static function passing_fixture_data_provider(): array {
5365 * @return array<array<string|array<string>>>
5466 */
5567 public static function failing_fixture_data_provider (): array {
56- return self ::get_files_in_directory ( __DIR__ . '/fixtures/fail ' );
68+ $ data = self ::get_files_in_directory ( __DIR__ . '/fixtures/fail ' );
69+ $ expectations = self ::get_files_in_directory ( __DIR__ . '/fixtures/fail/expectations ' );
70+
71+ foreach ( $ data as $ key => $ data_set ) {
72+ if ( ! isset ( $ expectations [ $ key ] ) ) {
73+ $ data [ $ key ][] = null ;
74+ continue ;
75+ }
76+
77+ $ data [ $ key ][] = $ expectations [ $ key ][0 ];
78+ }
79+
80+ return $ data ;
5781 }
5882
5983 /**
@@ -76,6 +100,10 @@ protected static function get_files_in_directory( string $directory ): array {
76100 $ data = [];
77101
78102 foreach ( $ files as $ file ) {
103+ if ( is_dir ( $ file ) ) {
104+ continue ;
105+ }
106+
79107 $ data [ basename ( $ file ) ] = [ $ file ];
80108 }
81109
0 commit comments