src/Codeception/Module/WPDb.php
public function dontHaveTermInDatabase(array $criteria, $purgeMeta = true)
    {
        $termRelationshipsKeys = ['term_taxonomy_id'];

        $termTableCriteria = array_intersect_key($criteria, array_flip($this->termKeys));
        $termTaxonomyTableCriteria = array_intersect_key($criteria, array_flip($this->termTaxonomyKeys));

        if ($purgeMeta) {
            $ids = false;

            if (!empty($termTableCriteria)) {
                $ids = $this->grabAllFromDatabase($this->grabTermsTableName(), 'term_id', $criteria);
            } elseif (!empty($termTaxonomyTableCriteria)) {
                $ids = $this->grabAllFromDatabase($this->grabTermTaxonomyTableName(), 'term_id', $criteria);
            }

            if (!empty($ids)) {
                foreach ($ids as $id) {
                    $this->dontHaveTermMetaInDatabase($id);
                }
            }
        }

        $this->dontHaveInDatabase($this->grabTermsTableName(), $termTableCriteria);
        $this->dontHaveInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyTableCriteria);
        $this->dontHaveInDatabase(
            $this->grabTermRelationshipsTableName(),
            array_intersect_key($criteria, array_flip($termRelationshipsKeys))
        );
    }
public function dontHaveTermInDatabase(array $criteria, $purgeMeta = true)
    {
        $termRelationshipsKeys = ['term_taxonomy_id'];

        $termTableCriteria = array_intersect_key($criteria, array_flip($this->termKeys));
        $termTaxonomyTableCriteria = array_intersect_key($criteria, array_flip($this->termTaxonomyKeys));

        if ($purgeMeta) {
            $ids = false;

            if (!empty($termTableCriteria)) {
                $ids = $this->grabAllFromDatabase($this->grabTermsTableName(), 'term_id', $criteria);
            } elseif (!empty($termTaxonomyTableCriteria)) {
                $ids = $this->grabAllFromDatabase($this->grabTermTaxonomyTableName(), 'term_id', $criteria);
            }

            if (!empty($ids)) {
                foreach ($ids as $id) {
                    $this->dontHaveTermMetaInDatabase($id);
                }
            }
        }

        $this->dontHaveInDatabase($this->grabTermsTableName(), $termTableCriteria);
        $this->dontHaveInDatabase($this->grabTermTaxonomyTableName(), $termTaxonomyTableCriteria);
        $this->dontHaveInDatabase(
            $this->grabTermRelationshipsTableName(),
            array_intersect_key($criteria, array_flip($termRelationshipsKeys))
        );
    }
public function dontHaveTermInDatabase ( array $ criteria , $ purgeMeta = true ) { $ termRelationshipsKeys = [ 'term_taxonomy_id' ] ; $ termTableCriteria = array_intersect_key ( $ criteria , array_flip ( $ this -> termKeys ) ) ; $ termTaxonomyTableCriteria = array_intersect_key ( $ criteria , array_flip ( $ this -> termTaxonomyKeys ) ) ; if ( $ purgeMeta ) { $ ids = false ; if ( ! empty ( $ termTableCriteria ) ) { $ ids = $ this -> grabAllFromDatabase ( $ this -> grabTermsTableName ( ) , 'term_id' , $ criteria ) ; } elseif ( ! empty ( $ termTaxonomyTableCriteria ) ) { $ ids = $ this -> grabAllFromDatabase ( $ this -> grabTermTaxonomyTableName ( ) , 'term_id' , $ criteria ) ; } if ( ! empty ( $ ids ) ) { foreach ( $ ids as $ id ) { $ this -> dontHaveTermMetaInDatabase ( $ id ) ; } } } $ this -> dontHaveInDatabase ( $ this -> grabTermsTableName ( ) , $ termTableCriteria ) ; $ this -> dontHaveInDatabase ( $ this -> grabTermTaxonomyTableName ( ) , $ termTaxonomyTableCriteria ) ; $ this -> dontHaveInDatabase ( $ this -> grabTermRelationshipsTableName ( ) , array_intersect_key ( $ criteria , array_flip ( $ termRelationshipsKeys ) ) ) ; }
Removes a term from the database.

@example
```php
$I->dontHaveTermInDatabase(['name' => 'romance']);
$I->dontHaveTermInDatabase(['slug' => 'genre--romance']);
```

@param array $criteria  An array of search criteria.
@param bool  $purgeMeta Whether the terms meta should be purged along side with the meta or not.
Removes a term from the database .