user = $this->factory->user->create( array( 'role' => 'administrator', ) ); } /** * Test that sample product data is imported. */ public function test_import_sample_products() { wp_set_current_user( $this->user ); $request = new WP_REST_Request( 'POST', $this->endpoint . '/import_sample_products' ); $response = $this->server->dispatch( $request ); $data = $response->get_data(); $this->assertEquals( 200, $response->get_status() ); $this->assertArrayHasKey( 'failed', $data ); $this->assertArrayHasKey( 'imported', $data ); $this->assertArrayHasKey( 'skipped', $data ); $this->assertArrayHasKey( 'updated', $data ); } }