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 = Uuid::generate(4); $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()); } }