Skip to content

Instantly share code, notes, and snippets.

@alexandreelise
Created October 2, 2022 04:18
Show Gist options
  • Save alexandreelise/fff297d0159c5ae5317f3e61e3c88745 to your computer and use it in GitHub Desktop.
Save alexandreelise/fff297d0159c5ae5317f3e61e3c88745 to your computer and use it in GitHub Desktop.
SmokeTest using PhpUnit and Joomla Framework Http package
<?php
namespace AlexApi\Tests;
use Generator;
use Joomla\Http\HttpFactory;
use Joomla\Uri\Uri;
use PHPUnit\Framework\TestCase;
class SmokeTest extends TestCase
{
/**
* @dataProvider urlProvider
*/
public function testPageIsSuccessful($path, $query)
{
$client = (new HttpFactory())->getAvailableDriver();
$uri = new Uri('https://example.org');
$uri->setPath($path);
$uri->setQuery($query);
$response = $client->request('GET', $uri);
$this->assertSame(200, $response->getStatusCode());
}
/**
* @return \Generator
*/
public function urlProvider(): Generator
{
yield ['/', ''];
yield ['/administrator', ''];
yield ['/sample-1', ''];
yield ['/your-favorite-cms', ''];
yield ['/blog', ''];
yield ['/contact', ''];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment