Skip to content

Commit

Permalink
set default value for position amount
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKrisKrisu committed Aug 22, 2020
1 parent 1a0a9ff commit b052559
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Position.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ public function getWeight()
*/
public function getAmount()
{
if ($this->amount === NULL && $this->weight === NULL)
return 1;
return $this->amount;
}

Expand Down
7 changes: 5 additions & 2 deletions tests/ReceiptParsingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ public function testBonParsingWeight(): void
$this->assertEquals(2, $receipt->getCashregisterNr());
$this->assertEquals(5, $receipt->getEarnedPaybackPoints());
$this->assertContains("EC-Cash", $receipt->getPaymentMethods());
$this->assertTrue( $receipt->hasPayedCashless());
$this->assertTrue( $receipt->hasPayedContactless());
$this->assertTrue($receipt->hasPayedCashless());
$this->assertTrue($receipt->hasPayedContactless());
$this->assertEquals(1577880000, $receipt->getTimestamp()->getTimestamp());

$this->assertEquals(1, $receipt->getPositionByName('BROT')->getAmount());
$this->assertNull($receipt->getPositionByName('BROT')->getWeight());
$this->assertEquals(1, $receipt->getPositionByName('BROT')->getPriceSingle());
$this->assertEquals(0.5, $receipt->getPositionByName('AUFSCHNITT')->getPriceSingle());
$this->assertEquals(0.5, $receipt->getPositionByName('NATUR-JOGHURT')->getPriceSingle());
Expand Down

0 comments on commit b052559

Please sign in to comment.