initial commit
This commit is contained in:
86
tests/unit/Laravel5/PersonTest.php
Normal file
86
tests/unit/Laravel5/PersonTest.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
namespace Laravel5;
|
||||
|
||||
use Codeception\TestCase\Test;
|
||||
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
|
||||
use XaiCorp\AbcParser\Models\Laravel5\Person;
|
||||
|
||||
class PersonTest extends Test
|
||||
{
|
||||
use TestHelperTrait;
|
||||
|
||||
/**
|
||||
* @var \UnitTester
|
||||
*/
|
||||
protected $tester;
|
||||
|
||||
/**
|
||||
* Define environment setup.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
* @return void
|
||||
*/
|
||||
protected function getEnvironmentSetUp($app)
|
||||
{
|
||||
// Setup default database to use sqlite :memory:
|
||||
$app['config']->set('database.default', 'testbench');
|
||||
$app['config']->set('database.connections.testbench', [
|
||||
'driver' => 'mysql',
|
||||
'host' => 'localhost',
|
||||
'database' => 'abc-api-testing',
|
||||
'charset' => 'utf8',
|
||||
'collation' => 'utf8_unicode_ci',
|
||||
'prefix' => '',
|
||||
'strict' => false,
|
||||
'username' => 'abc-api',
|
||||
'password' => 'sio2nf0d'
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->startApplication();
|
||||
$db = app()->make('db');
|
||||
$db->beginTransaction();
|
||||
|
||||
$this->withFactories(__DIR__.'/factories');
|
||||
}
|
||||
|
||||
protected function _after()
|
||||
{
|
||||
$db = app()->make('db');
|
||||
$db->rollBack();
|
||||
$this->stopApplication();
|
||||
}
|
||||
|
||||
// tests: trying to...
|
||||
|
||||
public function testMakeModel()
|
||||
{
|
||||
$name = "test1";
|
||||
$model = new Person();
|
||||
$model->name = $name;
|
||||
|
||||
$this->assertInstanceOf(Person::class, $model);
|
||||
$this->assertEquals($name, $model->name);
|
||||
}
|
||||
|
||||
public function testNameIsMassAssignable()
|
||||
{
|
||||
$name = "test1";
|
||||
$model = Person::create(['name'=>$name]);
|
||||
|
||||
$this->assertInstanceOf(Person::class, $model);
|
||||
$this->assertEquals($name, $model->name);
|
||||
}
|
||||
|
||||
public function testFactorySetsName()
|
||||
{
|
||||
$model = factory(Person::class)->make([]);
|
||||
|
||||
$this->assertInstanceOf(Person::class, $model);
|
||||
$this->assertNotEmpty($model->name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user