Aug 17, 2017
0
Level 8
Kind of a gross functional test. How to improve it, maybe?
GIVEN that we have a Character with a Type that has a Might pool value and a Descriptor that has a Might bonus value
WHEN we run that character through the calculation rules for rendering
THEN the Character's Might will be calculated accurately
public function it_calculates_might_accurately()
{
$this->signIn();
$stat = Stat::findOrFail(Stat::MIGHT);
$type = create(Type::class);
$type->stats()->save($stat);
$type->stats[0]->pivot->pool = 10;
$type->save();
$descriptor = create(Descriptor::class);
$descriptor->stats()->save($stat);
$descriptor->stats[0]->pivot->bonus = 2;
$descriptor->save();
$characterModel = new ModelCharacter();
$characterModel->type()->associate($type);
$characterModel->descriptor()->associate($descriptor);
$characterRender = new RenderCharacter($characterModel);
$this->assertEquals(12, $characterRender->stats[Stat::MIGHT]->pool);
}
Laravel 5.5. The only thing I seed into the database for my tests is the core rule stats.
I probably don't need the signIn() since I'm never saving the character.
Please or to participate in this conversation.