initial commit

This commit is contained in:
2016-04-15 21:38:56 -04:00
commit 1d3e8e3117
79 changed files with 16223 additions and 0 deletions

View File

@@ -0,0 +1,156 @@
<?php
namespace Laravel5;
use Codeception\TestCase\Test;
use Aedart\Testing\Laravel\Traits\TestHelperTrait;
use XaiCorp\AbcParser\Models\Laravel5\Person;
use XaiCorp\AbcParser\Models\Laravel5\Tune;
use XaiCorp\AbcParser\Models\Laravel5\TuneAttribute;
class TuneAttributeTest 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()
{
$tune = factory(Tune::class)->create();
$type = 'Title';
$title = 'a title';
$ordering = 1;
$model = new TuneAttribute();
$model->tune_id = $tune->id;
$model->type = $type;
$model->string = $title;
$model->ordering = $ordering;
$this->assertInstanceOf(TuneAttribute::class, $model);
$this->assertEquals($tune->id, $model->tune_id);
$this->assertEquals($type, $model->type);
$this->assertEquals($title, $model->string);
$this->assertEquals($ordering, $model->ordering);
}
public function testMassAssignable()
{
$tune = factory(Tune::class)->create();
$type = 'Title';
$title = 'a title';
$ordering = 1;
$model = TuneAttribute::create([
'tune_id' => $tune->id,
'type' => $type,
'string' => $title,
'ordering' => $ordering
]);
$this->assertInstanceOf(TuneAttribute::class, $model);
$this->assertEquals($tune->id, $model->tune_id);
$this->assertEquals($type, $model->type);
$this->assertEquals($title, $model->string);
$this->assertEquals($ordering, $model->ordering);
}
public function testFactory()
{
$model = factory(TuneAttribute::class)->make([]);
$this->assertInstanceOf(TuneAttribute::class, $model);
$this->assertNotNull($model->tune_id);
$this->assertNotNull($model->type);
$this->assertNotNull($model->string);
$this->assertNotNull($model->ordering);
$this->assertTrue($model->save(), json_encode($model->getMessages()));
}
public function testValidationAppliedOnSave()
{
$model = factory(TuneAttribute::class)->make([]);
$model->type = 'NotType';
$this->assertFalse($model->save());
}
public function testTypeValidation()
{
$model = factory(TuneAttribute::class)->make([]);
$model->type = 'NotType';
$this->assertFalse($model->validate());
}
public function testTuneIdValidation()
{
$model = factory(TuneAttribute::class)->make([]);
$model->tune_id += 1;
$this->assertFalse($model->validate());
}
public function testStringValidation()
{
$longString = '';
for ($i=0; $i < 300; $i++) {
$longString .= 's';
}
$model = factory(TuneAttribute::class)->make([]);
$model->string = $longString;
$this->assertFalse($model->validate());
}
public function testOrderingValidation()
{
$model = factory(TuneAttribute::class)->make([]);
$model->ordering = "fourth";
$this->assertFalse($model->validate());
}
}