Skip to content

Commit

Permalink
improve StockKeepingUnit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fivell authored and gigorok committed Jan 4, 2019
1 parent 1f1d99b commit 1310ad7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 21 deletions.
6 changes: 3 additions & 3 deletions src/Item/StockKeepingUnit.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ class StockKeepingUnit extends BaseItem

public function getSetupPrice(): float
{
return (float) $this->getAttributes()['setup_price'];
return (float) $this->attributes['setup_price'];
}

public function getMonthlyPrice(): float
{
return (float) $this->getAttributes()['monthly_price'];
return (float) $this->attributes['monthly_price'];
}

public function getChannelsIncludedCount()
{
return $this->getAttributes()['channels_included_count'];
return $this->attributes['channels_included_count'];
}
}
28 changes: 10 additions & 18 deletions tests/DidGroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,16 @@ public function testFind()
'name' => 'Local',
]);

$this->assertContainsOnlyInstancesOf('Didww\Item\StockKeepingUnit', $stockKeepingUnitsRelation->getIncluded()->all());
$this->assertEquals(array_map(
function ($value) {
return $value->getAttributes();
},
$stockKeepingUnitsRelation->getIncluded()->all()
), [
[
'setup_price' => '0.4',
'monthly_price' => '0.8',
'channels_included_count' => 0,
],
[
'setup_price' => '1.0',
'monthly_price' => '4.8',
'channels_included_count' => 2,
],
]);
$stockKeepingUnits = $stockKeepingUnitsRelation->getIncluded()->all();
$this->assertContainsOnlyInstancesOf('Didww\Item\StockKeepingUnit', $stockKeepingUnits);

$this->assertEquals(0.4, $stockKeepingUnits[0]->getSetupPrice());
$this->assertEquals(0.8, $stockKeepingUnits[0]->getMonthlyPrice());
$this->assertEquals(0, $stockKeepingUnits[0]->getChannelsIncludedCount());

$this->assertEquals(1.0, $stockKeepingUnits[1]->getSetupPrice());
$this->assertEquals(4.8, $stockKeepingUnits[1]->getMonthlyPrice());
$this->assertEquals(2, $stockKeepingUnits[1]->getChannelsIncludedCount());

$this->stopVCR();
}
Expand Down

0 comments on commit 1310ad7

Please sign in to comment.