1. Go to this page and download the library: Download recca0120/package-phpunit 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/ */
recca0120 / package-phpunit example snippets
class DatabaseTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$app = App::getInstance();
$app->migrate('up');
}
public function tearDown()
{
$app = App::getInstance();
$app->migrate('down');
}
}
use Illuminate\Database\Eloquent\Model;
class DatabaseTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$app = App::getInstance();
$app->migrate('up');
}
public function tearDown()
{
$app = App::getInstance();
$app->migrate('down');
}
public function test_app_environment()
{
$this->assertEquals(App::environment(), 'testing');
}
public function test_insert_into_database()
{
$data = [
'test1' => 'test1',
'test2' => 'test2',
'test3' => 'test3',
];
$test = Test::create($data);
// $result = $test->toArray();
$this->assertEquals($test->id, 1);
$this->assertEquals($test->test1, $data['test1']);
$this->assertEquals($test->test2, $data['test2']);
$this->assertEquals($test->test3, $data['test3']);
}
}
class Test extends Model
{
protected $guarded = ['id'];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.