php-sdk icon indicating copy to clipboard operation
php-sdk copied to clipboard

Add assert builder

Open pashak09 opened this issue 4 years ago • 0 comments

I think it would be nice to be able to set asserts using methods such as:

->sqlQueriesCountGreaterThanOrEqual(3)
->httpRequestsCountEquals(1)

In this PR I have implemented some of this functionality, if you think that this is a good idea that is worthy of attention, let me know, I will try to add an implementation for all possible assertions.

Usage example:

$configuration = new Configuration();
$assertBuilder = $configuration->getAssertBuilder();
$assertBuilder
    ->sqlQueriesCountGreaterThanOrEqual(1, 'test')
    ->httpRequestsCountEquals(1);

At the moment I have implemented the following assertions:

 for sql
 sqlQueriesCountGreaterThanOrEqual(int $expected, string|null $name = null)
 sqlQueriesCountLessThanOrEqual(int $expected, string|null $name = null)
 sqlQueriesCountGreaterThan(int $expected, string|null $name = null)
 sqlQueriesCountCountLessThan(int $expected, string|null $name = null)
 sqlQueriesCountNotEquals(int $expected, string|null $name = null)
 sqlQueriesCountEquals(int $expected, string|null $name = null)
 for http
 httpRequestsCountGreaterThanOrEqual(int $expected, string|null $name = null)
 httpRequestsCountLessThanOrEqual(int $expected, string|null $name = null)
 httpRequestsCountGreaterThan(int $expected, string|null $name = null)
 httpRequestsCountCountLessThan(int $expected, string|null $name = null)
 httpRequestsCountNotEquals(int $expected, string|null $name = null)
 httpRequestsCountEquals(int $expected, string|null $name = null)

pashak09 avatar Sep 16 '21 18:09 pashak09