diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-03-07 16:50:36 -0500 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-03-07 16:50:36 -0500 |
commit | 732899564517c6efd9ef965f3f843309a222ce50 (patch) | |
tree | bc49df0d3685c6f6447b4e74146ef3f8bc8aa730 /tests/units | |
parent | 313318a40da51575212c8d299fa1b2ed4c83ca1b (diff) |
Add user cost
Diffstat (limited to 'tests/units')
-rw-r--r-- | tests/units/HourlyRate.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/units/HourlyRate.php b/tests/units/HourlyRate.php new file mode 100644 index 00000000..5daf0446 --- /dev/null +++ b/tests/units/HourlyRate.php @@ -0,0 +1,43 @@ +<?php + +require_once __DIR__.'/Base.php'; + +use Model\User; +use Model\HourlyRate; + +class HourlyRateTest extends Base +{ + public function testCreation() + { + $hr = new HourlyRate($this->container); + $this->assertEquals(1, $hr->create(1, 32.4, 'EUR', '2015-01-01')); + $this->assertEquals(2, $hr->create(1, 42, 'CAD', '2015-02-01')); + + $rates = $hr->getAllByUser(0); + $this->assertEmpty($rates); + + $rates = $hr->getAllByUser(1); + $this->assertNotEmpty($rates); + $this->assertCount(2, $rates); + + $this->assertEquals(42, $rates[0]['rate']); + $this->assertEquals('CAD', $rates[0]['currency']); + $this->assertEquals('2015-02-01', date('Y-m-d', $rates[0]['date_effective'])); + + $this->assertEquals(32.4, $rates[1]['rate']); + $this->assertEquals('EUR', $rates[1]['currency']); + $this->assertEquals('2015-01-01', date('Y-m-d', $rates[1]['date_effective'])); + + $this->assertEquals(0, $hr->getCurrentRate(0)); + $this->assertEquals(42, $hr->getCurrentRate(1)); + + $this->assertTrue($hr->remove(2)); + $this->assertEquals(32.4, $hr->getCurrentRate(1)); + + $this->assertTrue($hr->remove(1)); + $this->assertEquals(0, $hr->getCurrentRate(1)); + + $rates = $hr->getAllByUser(1); + $this->assertEmpty($rates); + } +} |