From 5356df262f5b21016466be5668b1e49f674a9b12 Mon Sep 17 00:00:00 2001 From: Andrey Savchenko Date: Fri, 28 Dec 2018 14:55:47 +0200 Subject: [PATCH] Added hook formatter test. --- tests/Formatter/HookTest.php | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/Formatter/HookTest.php diff --git a/tests/Formatter/HookTest.php b/tests/Formatter/HookTest.php new file mode 100644 index 0000000..0560169 --- /dev/null +++ b/tests/Formatter/HookTest.php @@ -0,0 +1,55 @@ +zeroOrMoreTimes()->andReturnFirstArg(); + + return new Hook_Formatter(); + } + + /** + * @depends test__construct + */ + public function testFormat( Hook_Formatter $formatter ) { + + if ( ! defined( 'ABSPATH' ) ) { + define( 'ABSPATH', '/wp' ); + define( 'WP_CONTENT_DIR', '/wp-content/' ); + } + + Functions\expect( 'wp_normalize_path' )->zeroOrMoreTimes()->andReturnFirstArg(); + + $hook = [ + [ [ 'function' => 'function', 'accepted_args' => 2 ] ], + [ [ 'function' => [ 'class', 'method' ], 'accepted_args' => 1 ] ], + ]; + + $result = $formatter->format( $hook ); + + $this->assertInternalType( 'array', $result ); + $this->assertArraySubset( [ 'function(2)', 'class::method' ], array_values( $result ) ); + } +} +