forked from WordPress/wordpress-develop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfactory.php
More file actions
31 lines (26 loc) · 1.04 KB
/
factory.php
File metadata and controls
31 lines (26 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
class TestFactoryFor extends WP_UnitTestCase {
function setUp() {
parent::setUp();
$this->category_factory = new WP_UnitTest_Factory_For_Term( null, 'category' );
}
function test_create_creates_a_category() {
$id = $this->category_factory->create();
$this->assertTrue( (bool)get_term_by( 'id', $id, 'category' ) );
}
function test_get_object_by_id_gets_an_object() {
$id = $this->category_factory->create();
$this->assertTrue( (bool)$this->category_factory->get_object_by_id( $id ) );
}
function test_get_object_by_id_gets_an_object_with_the_same_name() {
$id = $this->category_factory->create( array( 'name' => 'Boo') );
$object = $this->category_factory->get_object_by_id( $id );
$this->assertEquals( 'Boo', $object->name );
}
function test_the_taxonomy_argument_overrules_the_factory_taxonomy() {
$term_factory = new WP_UnitTest_Factory_For_term( null, 'category' );
$id = $term_factory->create( array( 'taxonomy' => 'post_tag' ) );
$term = get_term( $id, 'post_tag' );
$this->assertEquals( $id, $term->term_id );
}
}