php-sdk
php-sdk copied to clipboard
Define assertions directly from your test
I want to be able to specify assertions directly in the test itself, not just in the .blackfire.yaml file.
You can see an example of a test below:
class BlackfireTest extends BlackfireTestCase
{
use TestCaseTrait;
protected const BLACKFIRE_SCENARIO_AUTO_START = false;
/**
* @group Blackfire
*
* @requires extension blackfire
*/
public function testBlackfireSuccessesResponse()
{
$configuration = new Configuration();
$configuration->assert('metrics.sql.queries.count == 1', 'SQL queries');
$configuration->assert('metrics.http.requests.count == 1', 'HTTP Requests');
$configuration->setUuid(Uuid::v4()->toRfc4122());
$client = static::createBlackfiredHttpBrowserClient();
$client->setConfiguration($configuration);
$client->request(
Request::METHOD_GET,
'/blackfire?username=test',
[],
[],
['HTTP_ACCEPT' => 'application/json']
);
$this->assertBlackfireIsSuccessful($configuration);
}
}
I also need this functionality. I am looking forward to your approval.
I think it's a good idea to keep assertions and test code in one place.