|
| 1 | +<?php |
| 2 | +declare(strict_types=1); |
| 3 | + |
| 4 | +namespace TIG\PostNL\Test\Unit\Service\Customer; |
| 5 | + |
| 6 | +use Magento\Customer\Helper\Address; |
| 7 | +use TIG\PostNL\Service\Customer\Data; |
| 8 | +use TIG\PostNL\Test\TestCase; |
| 9 | + |
| 10 | +class DataTest extends TestCase |
| 11 | +{ |
| 12 | + private $addressHelperMock; |
| 13 | + private Data $data; |
| 14 | + |
| 15 | + protected function setUp(): void |
| 16 | + { |
| 17 | + $this->addressHelperMock = $this->createMock(Address::class); |
| 18 | + $this->data = new Data($this->addressHelperMock); |
| 19 | + |
| 20 | + parent::setUp(); |
| 21 | + } |
| 22 | + |
| 23 | + public function testGetAddressLinesExtendCountReturnsInitialValue() |
| 24 | + { |
| 25 | + $this->assertSame(0, $this->data->getAddressLinesExtendCount()); |
| 26 | + } |
| 27 | + |
| 28 | + public function testCanExtendAddressLinesReturnsTrueWhenAllowedLinesLessThanMax() |
| 29 | + { |
| 30 | + $this->addressHelperMock->method('getStreetLines')->willReturn(2); |
| 31 | + $this->assertTrue($this->data->canExtendAddressLines()); |
| 32 | + } |
| 33 | + |
| 34 | + public function testCanExtendAddressLinesReturnsFalseWhenAllowedLinesEqualOrGreaterThanMax() |
| 35 | + { |
| 36 | + $this->addressHelperMock->method('getStreetLines')->willReturn(3); |
| 37 | + $this->assertFalse($this->data->canExtendAddressLines()); |
| 38 | + |
| 39 | + $this->addressHelperMock->method('getStreetLines')->willReturn(4); |
| 40 | + $this->assertFalse($this->data->canExtendAddressLines()); |
| 41 | + } |
| 42 | + |
| 43 | + public function testSetAddressLineExtendSetsValueWhenCanExtend() |
| 44 | + { |
| 45 | + $this->addressHelperMock->method('getStreetLines')->willReturn(2); |
| 46 | + $this->data->setAddressLineExtend(); |
| 47 | + $this->assertSame(1, $this->data->getAddressLinesExtendCount()); |
| 48 | + } |
| 49 | + |
| 50 | + public function testSetAddressLineExtendDoesNothingWhenCannotExtend() |
| 51 | + { |
| 52 | + $this->addressHelperMock->method('getStreetLines')->willReturn(3); |
| 53 | + $this->data->setAddressLineExtend(); |
| 54 | + $this->assertSame(0, $this->data->getAddressLinesExtendCount()); |
| 55 | + } |
| 56 | +} |
0 commit comments