src/Codeception/Module/WPQueries.php
public function assertQueriesCountByStatementAndFilter($n, $statement, $filter, $message = '')
    {
        $this->readQueries();
        $message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by filter  ['
                               . $filter . '] containing statement [' . $statement . ']';
        $iterator = new MainStatementQueriesFilter(new FiltersQueriesFilter(
            new \ArrayIterator($this->filteredQueries),
            $filter
        ), $statement);
        Assert::assertCount($n, iterator_to_array($iterator), $message);
    }
public function assertQueriesCountByStatementAndFilter($n, $statement, $filter, $message = '')
    {
        $this->readQueries();
        $message = $message ?: 'Failed asserting that ' . $n . ' queries were triggered by filter  ['
                               . $filter . '] containing statement [' . $statement . ']';
        $iterator = new MainStatementQueriesFilter(new FiltersQueriesFilter(
            new \ArrayIterator($this->filteredQueries),
            $filter
        ), $statement);
        Assert::assertCount($n, iterator_to_array($iterator), $message);
    }
public function assertQueriesCountByStatementAndFilter ( $ n , $ statement , $ filter , $ message = '' ) { $ this -> readQueries ( ) ; $ message = $ message ? : 'Failed asserting that ' . $ n . ' queries were triggered by filter  [' . $ filter . '] containing statement [' . $ statement . ']' ; $ iterator = new MainStatementQueriesFilter ( new FiltersQueriesFilter ( new \ ArrayIterator ( $ this -> filteredQueries ) , $ filter ) , $ statement ) ; Assert :: assertCount ( $ n , iterator_to_array ( $ iterator ) , $ message ) ; }
Asserts that n queries were made as a consequence of the specified filter containing the specified SQL statement.

Queries generated by `setUp`, `tearDown` and `factory` methods are excluded by default.

@example
```php
add_filter('the_title', function($title, $postId){
$post = get_post($postId);
if($post->post_type !== 'book'){
return $title;
}
$new = get_option('acme_new_prefix');
return "{$new} - " . $title;
});
// Warm up the cache.
$title = apply_filters('the_title', get_post($bookOneId)->post_title, $bookOneId);
// Cache is warmed up now.
$title = apply_filters('the_title', get_post($bookTwoId)->post_title, $bookTwoId);
$title = apply_filters('the_title', get_post($bookThreeId)->post_title, $bookThreeId);
$this->assertQueriesCountByStatementAndFilter(1, 'SELECT', 'the_title');
```

@param int $n The expected number of queries.
@param string $statement A simple string the statement should start with or a valid regular expression.
Regular expressions must contain delimiters.
@param string $filter The filter name, e.g. 'posts_where'.
@param string $message An optional message to override the default one.
Asserts that n queries were made as a consequence of the specified filter containing the specified SQL statement .