Passed
Pull Request — master (#59)
by Raúl
04:00
created

OrderHistoryTest::testSetDateOfBirth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 46
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 37
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 46
rs 9.328
1
<?php
2
3
namespace Test\Pagantis\OrdersApiClient\Model\Order\User;
4
5
use Faker\Factory;
6
use Pagantis\OrdersApiClient\Model\Order\User\OrderHistory;
7
use Test\Pagantis\OrdersApiClient\AbstractTest;
8
9
/**
10
 * Class OrderHistoryTest
11
 * @package Test\Pagantis\OrdersApiClient\Model\Order\User
12
 */
13
class OrderHistoryTest extends AbstractTest
14
{
15
    /**
16
     * testSetAmount
17
     */
18
    public function testSetAmount()
19
    {
20
        $faker = Factory::create();
21
        $number = $faker->randomDigitNotNull;
22
        $orderHistory = new OrderHistory();
23
        $orderHistory->setAmount($number);
24
        $this->assertEquals($orderHistory->getAmount(), $number);
25
    }
26
27
    /**
28
     * testSetDateOfBirth
29
     */
30
    public function testSetDateOfBirth()
31
    {
32
        $beforeFiftyYears = date('Y-m-d', strtotime('-18 years'));
33
        $orderHistory = new OrderHistory();
34
        $this->assertNull($orderHistory->getDate());
35
        $orderHistory->setDate($beforeFiftyYears);
36
        $this->assertSame($beforeFiftyYears, $orderHistory->getDate());
37
38
        $nullDate = null;
39
        $orderHistory = new OrderHistory();
40
        $this->assertNull($orderHistory->getDate());
41
        $orderHistory->setDate($nullDate);
42
        $this->assertSame($nullDate, $orderHistory->getDate());
43
44
        $orderHistory = new OrderHistory();
45
        $this->assertNull($orderHistory->getDate());
46
        $orderHistory->setDate("31/7/2000 00:00:00");
47
        $this->assertNull($orderHistory->getDate());
48
49
        $orderHistory = new OrderHistory();
50
        $this->assertNull($orderHistory->getDate());
51
        $orderHistory->setDate("31/7/2000");
52
        $this->assertNull($orderHistory->getDate());
53
54
        $orderHistory = new OrderHistory();
55
        $this->assertNull($orderHistory->getDate());
56
        $orderHistory->setDate("null");
57
        $this->assertSame($orderHistory->getDate(), $nullDate);
58
59
        $orderHistory = new OrderHistory();
60
        $this->assertNull($orderHistory->getDate());
61
        $orderHistory->setDate("");
62
        $this->assertSame($orderHistory->getDate(), $nullDate);
63
64
        $orderHistory = new OrderHistory();
65
        $today = new \DateTime('today');
66
        $this->assertNull($orderHistory->getDate());
67
        $orderHistory->setDate($today);
0 ignored issues
show
Bug introduced by
$today of type DateTime is incompatible with the type string expected by parameter $date of Pagantis\OrdersApiClient...OrderHistory::setDate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

67
        $orderHistory->setDate(/** @scrutinizer ignore-type */ $today);
Loading history...
68
        $this->assertSame($today->format('Y-m-d'), $orderHistory->getDate());
69
70
        $originalDate = '1985-05-25';
71
        $bornDate = date('Y-m-d H:i:s', strtotime($originalDate));
72
        $orderHistory = new OrderHistory();
73
        $this->assertNull($orderHistory->getDate());
74
        $orderHistory->setDate($bornDate);
75
        $this->assertSame($originalDate, $orderHistory->getDate());
76
    }
77
}
78