(int) $GLOBALS['rss2cpt_test_terms'][ $taxonomy ][ (string) $value ] ); } /** * In-memory term creator for isolated tests. * * @param string $term Term name. * @param string $taxonomy Taxonomy slug. * @return array|\WP_Error */ function wp_insert_term( $term, $taxonomy ) { $taxonomy = (string) $taxonomy; $term = (string) $term; if ( ! isset( $GLOBALS['rss2cpt_test_terms'][ $taxonomy ] ) ) { $GLOBALS['rss2cpt_test_terms'][ $taxonomy ] = array(); } if ( isset( $GLOBALS['rss2cpt_test_terms'][ $taxonomy ][ $term ] ) ) { return array( 'term_id' => (int) $GLOBALS['rss2cpt_test_terms'][ $taxonomy ][ $term ] ); } $next = ( isset( $GLOBALS['rss2cpt_test_next_term_id'] ) ? (int) $GLOBALS['rss2cpt_test_next_term_id'] : 1 ); $GLOBALS['rss2cpt_test_next_term_id'] = $next + 1; $GLOBALS['rss2cpt_test_terms'][ $taxonomy ][ $term ] = $next; return array( 'term_id' => $next ); } /** * In-memory object-term linker for isolated tests. * * Records (post_id, term_ids[], taxonomy) on $GLOBALS['rss2cpt_test_object_terms']. * * @param int $object_id Object ID. * @param array|string $terms Term IDs or slugs. * @param string $taxonomy Taxonomy slug. */ function wp_set_object_terms( $object_id, $terms, $taxonomy ) { $terms = array_map( 'intval', (array) $terms ); $GLOBALS['rss2cpt_test_object_terms'][] = array( 'object_id' => (int) $object_id, 'term_ids' => $terms, 'taxonomy' => (string) $taxonomy, ); } /** * Minimal is_wp_error stub: tests construct WP_Error objects by hand. * * @param mixed $thing Thing to check. * @return bool */ function is_wp_error( $thing ) { return $thing instanceof \WP_Error; } require_once dirname( __DIR__ ) . '/src/Options.php'; require_once dirname( __DIR__ ) . '/src/Import/Importer.php';