Inheritance: extends WC_REST_Controller
Ejemplo n.º 1
0
 /**
  * Test to make sure we can RUN a tool correctly.
  *
  * @since 2.7.0
  */
 public function test_execute_system_tool()
 {
     wp_set_current_user($this->user);
     $tools_controller = new WC_REST_System_Status_Tools_Controller();
     $raw_tools = $tools_controller->get_tools();
     $raw_tool = $raw_tools['recount_terms'];
     $response = $this->server->dispatch(new WP_REST_Request('POST', '/wc/v1/system_status/tools/recount_terms'));
     $data = $response->get_data();
     $this->assertEquals('recount_terms', $data['id']);
     $this->assertEquals('Term counts', $data['name']);
     $this->assertEquals('Recount terms', $data['action']);
     $this->assertEquals('This tool will recount product terms - useful when changing your settings in a way which hides products from the catalog.', $data['description']);
     $this->assertTrue($data['success']);
     $response = $this->server->dispatch(new WP_REST_Request('POST', '/wc/v1/system_status/tools/not_a_real_tool'));
     $this->assertEquals(404, $response->get_status());
 }
Ejemplo n.º 2
0
 /**
  * Get tools.
  * @return array of tools
  */
 public static function get_tools()
 {
     $tools_controller = new WC_REST_System_Status_Tools_Controller();
     return $tools_controller->get_tools();
 }