GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#58)
by joseph
18:31
created

MoneyEmbeddableTest::itCanSetANewMoneyObject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\Financial;
4
5
use EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Interfaces\Objects\Financial\MoneyEmbeddableInterface;
6
use Money\Currency;
7
use Money\Money;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * Class MoneyEmbeddableTest
12
 *
13
 * @package EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\Financial
14
 * @coversDefaultClass \EdmondsCommerce\DoctrineStaticMeta\Entity\Embeddable\Objects\Financial\MoneyEmbeddable
15
 */
16
class MoneyEmbeddableTest extends TestCase
17
{
18
    /**
19
     * @var MoneyEmbeddable
20
     */
21
    private $embeddable;
22
23
    public function setup()
24
    {
25
        $this->embeddable = new MoneyEmbeddable();
26
        //using reflection as would happen with Doctrine hydrating an object
27
        $reflection = new \ReflectionObject($this->embeddable);
28
        $propAmount = $reflection->getProperty(MoneyEmbeddableInterface::EMBEDDED_PROP_AMOUNT);
29
        $propAmount->setAccessible(true);
30
        $propAmount->setValue($this->embeddable, 100);
31
        $propCurrencyCode = $reflection->getProperty(MoneyEmbeddableInterface::EMBEDDED_PROP_CURRENCY_CODE);
32
        $propCurrencyCode->setAccessible(true);
33
        $propCurrencyCode->setValue($this->embeddable, 'GBP');
34
    }
35
36
    /**
37
     * @test
38
     * @small
39
     * @covers ::getMoney()
40
     */
41
    public function itCanGetTheMoneyObject()
42
    {
43
        $actual = $this->embeddable->getMoney();
44
        $this->assertNotFalse($actual);
45
    }
46
47
    /**
48
     * @test
49
     * @small
50
     * @covers ::setMoney()
51
     */
52
    public function itCanSetANewMoneyObject()
53
    {
54
        $newMoney = new Money(200, new Currency('GBP'));
55
        $this->embeddable->setMoney($newMoney);
56
        $expected = $newMoney;
57
        $actual   = $this->embeddable->getMoney();
58
        $this->assertSame($expected, $actual);
59
    }
60
61
    /**
62
     * @test
63
     * @small
64
     * @covers ::addMoney()
65
     */
66
    public function itCanAddToTheMoney()
67
    {
68
        $toAdd = new Money(100, new Currency('GBP'));
69
        $this->embeddable->addMoney($toAdd);
70
        $expected = '200';
71
        $actual   = $this->embeddable->getMoney()->getAmount();
72
        $this->assertSame($expected, $actual);
73
    }
74
75
    /**
76
     * @test
77
     * @small
78
     * @covers ::subtractMoney()
79
     */
80
    public function itCanSubtractFromTheMoney()
81
    {
82
        $toSubtract = new Money(60, new Currency('GBP'));
83
        $this->embeddable->subtractMoney($toSubtract);
84
        $expected = '40';
85
        $actual   = $this->embeddable->getMoney()->getAmount();
86
        $this->assertSame($expected, $actual);
87
    }
88
}
89