Example #1
0
 /**
  * Test that when we ask for too high of a page, we get nothing back
  *
  * @since 0.0.7
  *
  * @group crud
  * @group group
  * @group group_crud
  *
  * @covers \ingot\testing\crud\group::get_items()
  */
 public function testGetItemsPaginationTooHigh()
 {
     \ingot\testing\crud\group::delete('all');
     for ($i = 1; $i <= 11; $i++) {
         $params = array('name' => $i, 'type' => 'click', 'sub_type' => 'button', 'meta' => ['link' => 'https://bats.com']);
         $created[$i] = \ingot\testing\crud\group::create($params);
     }
     $params = array('limit' => 5, 'page' => 4);
     $items = \ingot\testing\crud\group::get_items($params);
     $this->assertEmpty($items);
 }
Example #2
0
 /**
  * Delete a group
  *
  * @since 0.4.0
  *
  * @param \WP_REST_Request $request Full data about the request.
  * @return \WP_Error|\WP_REST_Response
  */
 public function delete_item($request)
 {
     $url = $request->get_url_params();
     $id = helpers::v('id', $url, 0);
     $existing = group::read($id);
     if (!is_array($existing)) {
         if (is_wp_error($existing)) {
             return $existing;
         }
         return ingot_rest_response(['message' => esc_html__('No group found', 'ingot')]);
     }
     $deleted = group::delete($id);
     if ($deleted) {
         return ingot_rest_response(['message' => esc_html__('Group Deleted', 'ingot')], 204);
     }
 }
 public function setUp()
 {
     parent::setUp();
     \ingot\testing\crud\group::delete('all');
 }
Example #4
0
 /**
  * Test item exists method
  *
  * @since 1.1.0
  *
  * @group group
  * @group group_crud
  * @group crud
  *
  * @covers  \ingot\testing\crud\group::exists()
  */
 public function testExists()
 {
     $id = \ingot\testing\crud\group::create(['name' => 'd', 'type' => 'price', 'sub_type' => 'edd', 'meta' => ['product_ID' => 169], 'wp_ID' => 169], true);
     $this->assertTrue(is_numeric($id));
     $this->assertTrue(\ingot\testing\crud\group::exists($id));
     $this->assertFalse(\ingot\testing\crud\group::exists(99999));
     \ingot\testing\crud\group::delete($id);
     $this->assertFalse(\ingot\testing\crud\group::exists($id));
 }