PluginProbe
Stream – Activity Log & Audit Trail / 3.0.1
Stream – Activity Log & Audit Trail v3.0.1
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
stream / tests / testcase.php

testcase.php in Stream – Activity Log & Audit Trail 3.0.1, at tests/testcase.php

75 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace WP_Stream;
3
4 class WP_StreamTestCase extends \WP_UnitTestCase {
5 /**
6 * Holds the plugin base class
7 *
8 * @var Plugin
9 */
10 protected $plugin;
11
12 /**
13 * Custom action prefix for test custom triggered actions
14 * @var string
15 */
16 protected $action_prefix = 'wp_stream_test_';
17
18 /**
19 * PHP unit setup function
20 *
21 * @return void
22 */
23 function setUp() {
24 parent::setUp();
25 $this->plugin = $GLOBALS['wp_stream'];
26 $this->assertNotEmpty( $this->plugin );
27 }
28
29 /**
30 * Make sure the plugin is initialized with it's global variable
31 *
32 * @return void
33 */
34 public function test_plugin_initialized() {
35 $this->assertFalse( null == $this->plugin );
36 }
37
38 /**
39 * Helper function to check validity of action
40 *
41 * @param array $tests
42 * @param string $function_call
43 */
44 protected function do_action_validation( array $tests = array(), $function_call = 'has_action' ){
45 foreach ( $tests as $test ) {
46 list( $action, $class, $function ) = $test;
47
48 //Default WP priority
49 $priority = isset( $test[3] ) ? $test[3] : 10;
50
51 //Default function call
52 $function_call = ( in_array( $function_call, array( 'has_action', 'has_filter' ) ) ) ? $function_call : 'has_action';
53
54 //Run assertion here
55 $this->assertEquals(
56 $priority,
57 $function_call( $action, array( $class, $function ) ),
58 "$action $function_call is not attached to $class::$function. It might also have the wrong priority (validated priority: $priority)"
59 );
60 $this->assertTrue(
61 method_exists( $class, $function ),
62 "Class '$class' doesn't implement the '$function' function"
63 );
64 }
65 }
66
67 /**
68 * Helper function to check validity of filters
69 * @param array $tests
70 */
71 protected function do_filter_validation( array $tests = array() ){
72 $this->do_action_validation( $tests, 'has_filter' );
73 }
74 }
75