Skip to content

Commit

Permalink
Bump phpunit-polyfills and update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
delawski committed Jul 15, 2024
1 parent b701c4c commit 9818db6
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 47 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"wpackagist-plugin/user-switching": "1.5.5",
"wpackagist-theme/twentytwentythree": "^1.0",
"xwp/wait-for": "^0.0.1",
"yoast/phpunit-polyfills": "^1.0"
"yoast/phpunit-polyfills": "^1.1"
},
"config": {
"process-timeout": 600,
Expand Down
19 changes: 11 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 21 additions & 21 deletions tests/tests/test-class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ public function test_notice() {
$this->admin->admin_notices();
$notice = ob_get_clean();

$this->assertContains( $message, $notice );
$this->assertContains( 'updated', $notice );
$this->assertNotContains( 'error', $notice );
$this->assertStringContainsString( $message, $notice );
$this->assertStringContainsString( 'updated', $notice );
$this->assertStringNotContainsString( 'error', $notice );

// Clear notices and start again
$this->admin->notices = array();
Expand All @@ -96,9 +96,9 @@ public function test_notice() {
$this->admin->admin_notices();
$notice = ob_get_clean();

$this->assertContains( $message, $notice );
$this->assertContains( 'error', $notice );
$this->assertNotContains( 'updated', $notice );
$this->assertStringContainsString( $message, $notice );
$this->assertStringContainsString( 'error', $notice );
$this->assertStringNotContainsString( 'updated', $notice );

// Prevent output
$this->admin->notices = array();
Expand All @@ -122,10 +122,10 @@ public function test_admin_notices() {
$this->admin->admin_notices();
$notices = ob_get_clean();

$this->assertContains( $allowed_html, $notices );
$this->assertNotContains( $disallowed_html, $notices );
$this->assertContains( str_replace( $disallowed_html, '', $this->admin->notices[0]['message'] ), $notices );
$this->assertContains( wpautop( $this->admin->notices[1]['message'] ), $notices );
$this->assertStringContainsString( $allowed_html, $notices );
$this->assertStringNotContainsString( $disallowed_html, $notices );
$this->assertStringContainsString( str_replace( $disallowed_html, '', $this->admin->notices[0]['message'] ), $notices );
$this->assertStringContainsString( wpautop( $this->admin->notices[1]['message'] ), $notices );

// Prevent output
$this->admin->notices = array();
Expand Down Expand Up @@ -199,9 +199,9 @@ public function test_admin_body_class() {
$classes = 'sit-down-calmy take-a-stress-pill think-things-over';
$admin_body_classes = $this->admin->admin_body_class( $classes );

$this->assertContains( 'think-things-over ', $admin_body_classes );
$this->assertContains( $this->admin->admin_body_class . ' ', $admin_body_classes );
$this->assertContains( $this->admin->records_page_slug . ' ', $admin_body_classes );
$this->assertStringContainsString( 'think-things-over ', $admin_body_classes );
$this->assertStringContainsString( $this->admin->admin_body_class . ' ', $admin_body_classes );
$this->assertStringContainsString( $this->admin->records_page_slug . ' ', $admin_body_classes );
}

public function test_admin_menu_css() {
Expand All @@ -215,7 +215,7 @@ public function test_admin_menu_css() {
$dependency = $wp_styles->registered['wp-admin'];
$this->assertArrayHasKey( 'after', $dependency->extra );
$this->assertNotEmpty( $dependency->extra['after'] );
$this->assertContains( "#toplevel_page_{$this->admin->records_page_slug}", $dependency->extra['after'][0] );
$this->assertStringContainsString( "#toplevel_page_{$this->admin->records_page_slug}", $dependency->extra['after'][0] );
}

/*
Expand Down Expand Up @@ -312,9 +312,9 @@ public function test_plugin_action_links() {

$action_links = $this->admin->plugin_action_links( $links, $file );

$this->assertContains( 'Disconnect', $action_links[0] );
$this->assertContains( 'Settings', $action_links[1] );
$this->assertContains( 'Uninstall', $action_links[2] );
$this->assertStringContainsString( 'Disconnect', $action_links[0] );
$this->assertStringContainsString( 'Settings', $action_links[1] );
$this->assertStringContainsString( 'Uninstall', $action_links[2] );
}

public function test_render_list_table() {
Expand All @@ -324,16 +324,16 @@ public function test_render_list_table() {
$this->admin->render_list_table();
$html = ob_get_clean();

$this->assertContains( '<div class="wrap">', $html );
$this->assertContains( 'record-filter-form', $html );
$this->assertStringContainsString( '<div class="wrap">', $html );
$this->assertStringContainsString( 'record-filter-form', $html );
}

public function test_render_settings_page() {
ob_start();
$this->admin->render_settings_page();
$html = ob_get_clean();

$this->assertContains( '<div class="wrap">', $html );
$this->assertStringContainsString( '<div class="wrap">', $html );

global $wp_scripts;

Expand Down Expand Up @@ -410,7 +410,7 @@ public function test_ajax_filters() {
$data = json_decode( $json );
$this->assertNotFalse( $data );
$this->assertNotEmpty( $data );
$this->assertInternalType( 'array', $data );
$this->assertIsArray( $data );
}

public function test_get_users_record_meta() {
Expand Down
22 changes: 11 additions & 11 deletions tests/tests/test-class-alerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ function test_load_alerts_settings() {
}

$response = json_decode( $this->_last_response );
$this->assertInternalType( 'object', $response );
$this->assertObjectHasAttribute( 'success', $response );
$this->assertIsObject( $response );
$this->assertObjectHasProperty( 'success', $response );
$this->assertTrue( $response->success );
$this->assertObjectHasAttribute( 'data', $response );
$this->assertObjectHasProperty( 'data', $response );

}

Expand Down Expand Up @@ -323,8 +323,8 @@ function test_get_actions() {
}

$response = json_decode( $this->_last_response );
$this->assertInternalType( 'object', $response );
$this->assertObjectHasAttribute( 'success', $response );
$this->assertIsObject( $response );
$this->assertObjectHasProperty( 'success', $response );
$this->assertTrue( $response->success );
$this->assertNotEmpty( $response->data );
}
Expand All @@ -346,8 +346,8 @@ function test_save_new_alert_with_parent_context() {
}

$response = json_decode( $this->_last_response );
$this->assertInternalType( 'object', $response );
$this->assertObjectHasAttribute( 'success', $response );
$this->assertIsObject( $response );
$this->assertObjectHasProperty( 'success', $response );
$this->assertTrue( $response->success );
}
function test_save_new_alert_with_child_context() {
Expand All @@ -368,8 +368,8 @@ function test_save_new_alert_with_child_context() {
}

$response = json_decode( $this->_last_response );
$this->assertInternalType( 'object', $response );
$this->assertObjectHasAttribute( 'success', $response );
$this->assertIsObject( $response );
$this->assertObjectHasProperty( 'success', $response );
$this->assertTrue( $response->success );
}

Expand Down Expand Up @@ -502,8 +502,8 @@ function test_get_new_alert_triggers_notifications() {
}

$response = json_decode( $this->_last_response );
$this->assertInternalType( 'object', $response );
$this->assertObjectHasAttribute( 'success', $response );
$this->assertIsObject( $response );
$this->assertObjectHasProperty( 'success', $response );
$this->assertTrue( $response->success );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/tests/test-class-author.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function setUp(): void {
* Also tests private method locate_plugin
*/
public function test_construct() {
$this->assertInternalType( 'int', $this->author->id );
$this->assertIsInt( $this->author->id );
$this->assertNotEmpty( $this->author->id );
$this->assertInternalType( 'array', $this->author->meta );
$this->assertIsArray( $this->author->meta );
$this->assertNotEmpty( $this->author->meta );
}

Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test-class-connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function test_delayed_log() {
);

$this->assertNotEmpty( $this->connector->delayed[ $action ] );
$this->assertInternalType( 'array', $this->connector->delayed[ $action ] );
$this->assertIsArray( $this->connector->delayed[ $action ] );

global $wpdb;
$first_count = $wpdb->get_var( "SELECT COUNT( ID ) FROM {$wpdb->stream}" );
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/test-class-db-driver-wpdb.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function test_table_names() {
$table_names = $this->driver->get_table_names();

$this->assertNotEmpty( $table_names );
$this->assertInternalType( 'array', $table_names );
$this->assertIsArray( $table_names );
$this->assertEquals( array( $this->driver->table, $this->driver->table_meta ), $table_names );
}

Expand Down
4 changes: 2 additions & 2 deletions tests/tests/test-class-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function test_plugin_initialized() {
* Also tests private method locate_plugin
*/
public function test_construct() {
$this->assertInternalType( 'array', $this->plugin->locations );
$this->assertIsArray( $this->plugin->locations );
$this->assertNotEmpty( $this->plugin->locations );
$this->assertArrayHasKey( 'plugin', $this->plugin->locations );
$this->assertNotEmpty( $this->plugin->locations['plugin'] );
Expand Down Expand Up @@ -77,7 +77,7 @@ public function test_frontend_indicator() {
$comment = ob_get_clean();

$this->assertNotEmpty( $comment );
$this->assertContains( 'Stream WordPress user activity plugin', $comment );
$this->assertStringContainsString( 'Stream WordPress user activity plugin', $comment );
}

public function test_get_version() {
Expand Down

0 comments on commit 9818db6

Please sign in to comment.