1. Go to this page and download the library: Download luyadev/luya-testsuite library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
luyadev / luya-testsuite example snippets
namespace app\tests;
use Yii;
class MyTest extends \luya\testsuite\cases\WebApplicationTestCase
{
public function getConfigArray()
{
return [
'id' => 'mytestapp',
'basePath' => dirname(__DIR__),
];
}
public function testInstance()
{
// add your phpunit tests here, like:
$this->assertInstanceOf('luya\web\Application', Yii::$app);
$this->assertInstanceOf('luya\base\Boot', $this->boot);
$this->assertInstanceOf('luya\web\Application', $this->app);
}
}
namespace app\tests;
class MyWebsiteTest extends ServerTestCase
{
public function getConfigArray()
{
return [
'id' => 'mytestapp',
'basePath' => dirname(__DIR__),
];
}
public function testSites()
{
$this->assertUrlHomepageIsOk(); // checks the root url like: http://localhost/mywebsite.com
$this->assertUrlIsOk('about'); // checks: http://localhost/mywebsite.com/about
$this->assertUrlGetResponseContains('about/me', 'Hello World'); // checks: http://localhost/mywebsite.com/about/me
$this->assertUrlIsError('errorpage'); // checks: http://localhost/mywebsite.com/errorpage
}
}