function test_term_data() { $post_id = $this->factory->post->create(); wp_set_object_terms($post_id, 'some-term', 'category'); // replace existing, once wp_set_object_terms($post_id, 'some-term-2', 'category', true); wp_set_object_terms($post_id, 'some-term-3', 'category', true); $qq = new QQuery(); $post = $qq->id($post_id)->extend('terms')->go(); // var_dump($post); // $this->assertNotEmpty($post->terms); }
function test_get_post_in_array() { $howmany = 20; // larger than default page size $post_ids = $this->factory->post->create_many($howmany); shuffle($post_ids); $working_ids = array_slice($post_ids, 5); $qq = new QQuery(); // using array-based set of IDs $posts1 = $qq->id($working_ids)->all()->go(); // make sure we get the same number of posts as we requested $this->assertEquals(count($posts1), count($working_ids)); $posts2 = $qq->id(implode(',', $working_ids))->all()->go(); // make sure a comma-delimited set of ids is returning posts properly $this->assertEquals(count($posts2), count($working_ids)); $warning = false; try { $qq->id('')->go(); } catch (Exception $e) { $warning = true; } $this->assertTrue($warning, 'a warning has been caught'); }