Skip to content

Commit

Permalink
Merge pull request #56 from Zizaco/coverage-100
Browse files Browse the repository at this point in the history
100% coverage
  • Loading branch information
scottrobertson committed Jul 6, 2014
2 parents 105efbd + 27e2100 commit b534116
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion tests/FactoryMuffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function test_should_get_attributes_for()
public function test_date_kind()
{
$format = 'Y-m-d';

$this->factory->define('SampleModelA', array(
'created' => 'date|' . $format,
));
Expand Down Expand Up @@ -232,6 +232,36 @@ public function test_can_create_from_static_method()
$this->assertEquals('just a string', $obj->string);
$this->assertEquals(4, $obj->four);
}

/**
* @expectedException \Exception
* @expectedExceptionMessage does not have a static doesNotExist method
*/
public function test_throw_exception_when_invalid_static_method()
{
$obj = $this->factory->create('ModelWithMissingStaticMethod');
$obj->does_not_exist;
}

/**
* @expectedException \Zizaco\FactoryMuff\SaveException
* @expectedExceptionMessage Failed to save. - Could not save the model of type: SampleModelWithValidationErrors
*/
public function test_with_validation_errors()
{
$obj = $this->factory->create('SampleModelWithValidationErrors');
}
}

class SampleModelWithValidationErrors
{
public $factory = array();
public $validationErrors = 'Failed to save.';

public function save()
{

}
}

/**
Expand Down Expand Up @@ -398,6 +428,13 @@ public function save()
}
}

class ModelWithMissingStaticMethod
{
public static $factory = array(
'does_not_exist' => 'call|doesNotExist'
);
}

class ModelWithStaticMethodFactory
{
public static function factory()
Expand Down

0 comments on commit b534116

Please sign in to comment.