1
exercism fetch php change

change_test.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php

require "change.php";

class ChangeTest extends PHPUnit\Framework\TestCase
{
    public function testSingleCoinChange()
    {
        $this->assertEquals(array(25), findFewestCoins(array(1, 5, 10, 25, 100), 25));
    }

    public function testChange()
    {
        $this->markTestSkipped();
        $this->assertEquals(array(5, 10), findFewestCoins(array(1, 5, 10, 25, 100), 15));
    }

    public function testChangeWithLilliputianCoins()
    {
        $this->markTestSkipped();
        $this->assertEquals(array(4, 4, 15), findFewestCoins(array(1, 4, 15, 20, 50), 23));
    }

    public function testChangeWithLowerElboniaCoins()
    {
        $this->markTestSkipped();
        $this->assertEquals(array(21, 21, 21), findFewestCoins(array(1, 5, 10, 21, 25), 63));
    }

    public function testWithLargeTargetValue()
    {
        $this->markTestSkipped();
        $this->assertEquals(
            array(2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100),
            findFewestCoins(array(1, 2, 5, 10, 20, 50, 100), 999)
        );
    }

    public function testForChangeSmallerThanAvailableCoins()
    {
        $this->markTestSkipped();
        $this->expectException('InvalidArgumentException', 'No coins small enough to make change');
        findFewestCoins(array(5, 10), 3);
    }

    public function testNoCoinsForZero()
    {
        $this->markTestSkipped();
        $this->assertEquals(array(), findFewestCoins(array(1, 2, 5), 0));
    }

    public function testChangeValueLessThanZero()
    {
        $this->markTestSkipped();
        $this->expectException('InvalidArgumentException', 'Cannot make change for negative value');
        findFewestCoins(array(1, 2, 5), -5);
    }
}