summaryrefslogtreecommitdiff
path: root/tests/units/Validator/CurrencyValidatorTest.php
blob: 0b6467325cd20ae112553464c975cd082b04be6c (plain)
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
<?php

require_once __DIR__.'/../Base.php';

use Kanboard\Validator\CurrencyValidator;

class CurrencyValidatorTest extends Base
{
    public function testValidation()
    {
        $currencyValidator = new CurrencyValidator($this->container);
        $result = $currencyValidator->validateCreation(array());
        $this->assertFalse($result[0]);

        $result = $currencyValidator->validateCreation(array('currency' => 'EUR'));
        $this->assertFalse($result[0]);

        $result = $currencyValidator->validateCreation(array('rate' => 1.9));
        $this->assertFalse($result[0]);

        $result = $currencyValidator->validateCreation(array('currency' => 'EUR', 'rate' => 'foobar'));
        $this->assertFalse($result[0]);

        $result = $currencyValidator->validateCreation(array('currency' => 'EUR', 'rate' => 1.25));
        $this->assertTrue($result[0]);
    }
}