Skip to content

Instantly share code, notes, and snippets.

@mrself
Last active March 29, 2018 10:44
Show Gist options
  • Save mrself/5a9e5b5ed35e4b6178f15d86058a74e3 to your computer and use it in GitHub Desktop.
Save mrself/5a9e5b5ed35e4b6178f15d86058a74e3 to your computer and use it in GitHub Desktop.

Revisions

  1. mrself revised this gist Mar 29, 2018. 2 changed files with 27 additions and 0 deletions.
    1 change: 1 addition & 0 deletions TestCase1.php
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    public function testSmth() {
    $this->client = static::createClient();
    $crawler = $this->client->request('GET', '/my-test-page');
    if ($this->client->getResponse()->getStatusCode() !== 200) {
    dump($crawler->filter('.text-exception')->first()->text());
    26 changes: 26 additions & 0 deletions TestCase2.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    public function testSmth() {
    $this->client = static::createClient();
    $crawler = $this->client->request('GET', '/my-test-page');
    if ($this->client->getResponse()->getStatusCode() !== 200) {
    $profile = $this->client->getProfile();
    $exceptionProfile = $profile->getCollector('exception');
    $trace = $exceptionProfile->getTrace();
    $trace = array_slice($trace, 0, 5);
    $trace = array_map(function($i) {
    unset($i['short_class']);
    unset($i['namespace']);
    if ($i['file']) {
    $root = $this->container->getParameter('kernel.root_dir');
    $root = str_replace('app', '', $root);
    $i['file'] = str_replace($root, '', $i['file']);
    unset($i['class']);
    $i['file'] .= $i['type'] . $i['function'] . ':' . $i['line'];
    unset($i['line']);
    unset($i['type']);
    unset($i['function']);
    }
    return $i;
    }, $trace);
    dump($trace);
    throw new \Exception($exceptionProfile->getMessage());
    }
  2. mrself created this gist Mar 29, 2018.
    8 changes: 8 additions & 0 deletions TestCase1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    public function testSmth() {
    $crawler = $this->client->request('GET', '/my-test-page');
    if ($this->client->getResponse()->getStatusCode() !== 200) {
    dump($crawler->filter('.text-exception')->first()->text());
    dump($crawler->filter('.traces > li')->eq(0)->text());
    dump($crawler->filter('.traces > li')->eq(1)->text());
    throw new \Exception('Request to /my-test-page was not successfull');
    }