-
Notifications
You must be signed in to change notification settings - Fork 0
/
BigDecimalTypeTest.phpt
61 lines (44 loc) · 1.38 KB
/
BigDecimalTypeTest.phpt
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
59
60
61
<?php declare(strict_types = 1);
namespace GrandMediaTests\DoctrineTypes\Money;
use Brick\Math\BigDecimal;
use Doctrine\DBAL\Types\Type;
use GrandMedia\DoctrineTypes\Money\BigDecimalType;
use GrandMediaTests\DoctrineTypes\Mocks\Platform;
use Tester\Assert;
require_once __DIR__ . '/../../bootstrap.php';
/**
* @testCase
*/
final class BigDecimalTypeTest extends \Tester\TestCase
{
private const NUMBER = '123456789';
public function testGetSQLDeclaration(): void
{
$type = Type::getType(BigDecimalType::NAME);
Assert::same('VARCHAR(255)', $type->getSQLDeclaration([], new Platform()));
}
public function testConvertToPhpValue(): void
{
$platform = new Platform();
$type = Type::getType(BigDecimalType::NAME);
$number = BigDecimal::of(self::NUMBER);
Assert::true($number->isEqualTo($type->convertToPHPValue(self::NUMBER, $platform)));
Assert::type('null', $type->convertToPHPValue(null, $platform));
}
public function testGetName(): void
{
$type = Type::getType(BigDecimalType::NAME);
Assert::same(BigDecimalType::NAME, $type->getName());
}
public function testRequiresSQLCommentHint(): void
{
$type = Type::getType(BigDecimalType::NAME);
Assert::true($type->requiresSQLCommentHint(new Platform()));
}
protected function setUp(): void
{
parent::setUp();
Type::addType(BigDecimalType::NAME, BigDecimalType::class);
}
}
(new BigDecimalTypeTest())->run();