Skip to content

Commit

Permalink
add Callback error test
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Dec 27, 2021
1 parent b69d05b commit 9175df5
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/DemosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,32 @@ public function testDemoAssertJsonResponsePost(string $uri, array $postData): vo
$this->assertSame(200, $response->getStatusCode(), ' Status error on ' . $uri);
$this->assertMatchesRegularExpression($this->regexJson, $response->getBody()->getContents(), ' RegExp error on ' . $uri);
}

public function testCallbackError(): void
{
if (static::class === self::class) {
$this->expectException(\Atk4\Ui\Exception::class);
$this->expectExceptionMessage('Callback requested, but never reached. You may be missing some arguments in request URL.');
}

$uri = 'obsolete/notify2.php?' . Callback::URL_QUERY_TRIGGER_PREFIX . 'test_notify=ajax&' . Callback::URL_QUERY_TARGET . '=callback_trigger_error';
$data = [
'text' => 'This text will appear in notification',
'icon' => 'warning sign',
'color' => 'green',
'transition' => 'jiggle',
'width' => '25%',
'position' => 'topRight',
'attach' => 'Body',
];

try {
$this->getResponseFromRequest($uri, ['form_params' => $data]);
} catch (\GuzzleHttp\Exception\ServerException $e) {
$this->assertSame(500, $e->getResponse()->getStatusCode());
$this->assertStringContainsString('Callback requested, but never reached. You may be missing some arguments in request URL.', (string) $e->getResponse()->getBody());
}
}
}

class DemosTestExitError extends \Error
Expand Down

0 comments on commit 9175df5

Please sign in to comment.