thuecat/Tests/Unit/Domain/Model/Frontend/AddressTest.php

125 lines
3.3 KiB
PHP
Raw Normal View History

2021-02-16 12:02:10 +01:00
<?php
2021-08-10 09:55:15 +02:00
declare(strict_types=1);
2021-02-16 12:02:10 +01:00
namespace WerkraumMedia\ThueCat\Tests\Unit\Domain\Model\Frontend;
/*
* Copyright (C) 2021 Daniel Siepmann <coding@daniel-siepmann.de>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
use PHPUnit\Framework\Attributes\Test;
2021-02-16 12:02:10 +01:00
use PHPUnit\Framework\TestCase;
2021-02-16 15:08:15 +01:00
use WerkraumMedia\ThueCat\Domain\Model\Frontend\Address;
2021-02-16 12:02:10 +01:00
class AddressTest extends TestCase
{
#[Test]
2021-02-16 12:02:10 +01:00
public function canBeCreated(): void
{
$subject = new Address('[]');
self::assertInstanceOf(Address::class, $subject);
}
#[Test]
2021-02-16 12:02:10 +01:00
public function returnsProperDefaults(): void
{
$subject = new Address('[]');
self::assertSame('', $subject->getStreet());
self::assertSame('', $subject->getZip());
self::assertSame('', $subject->getCity());
self::assertSame('', $subject->getEmail());
self::assertSame('', $subject->getPhone());
self::assertSame('', $subject->getFax());
}
#[Test]
2021-02-16 12:02:10 +01:00
public function returnsStreet(): void
{
$subject = new Address('{"street": "Example Street 10"}');
self::assertSame('Example Street 10', $subject->getStreet());
}
#[Test]
2021-02-16 12:02:10 +01:00
public function returnsZip(): void
{
$subject = new Address('{"zip": "09084"}');
self::assertSame('09084', $subject->getZip());
}
#[Test]
2021-02-16 12:02:10 +01:00
public function returnsCity(): void
{
$subject = new Address('{"city": "Erfurt"}');
self::assertSame('Erfurt', $subject->getCity());
}
#[Test]
2021-02-16 12:02:10 +01:00
public function returnsEmail(): void
{
$subject = new Address('{"email": "example@example.com"}');
self::assertSame('example@example.com', $subject->getEmail());
}
#[Test]
2021-02-16 12:02:10 +01:00
public function returnsPhone(): void
{
$subject = new Address('{"phone": "+49 361 99999"}');
self::assertSame('+49 361 99999', $subject->getPhone());
}
#[Test]
2021-02-16 12:02:10 +01:00
public function returnsFax(): void
{
$subject = new Address('{"fax": "+49 361 99998"}');
self::assertSame('+49 361 99998', $subject->getFax());
}
#[Test]
2021-02-16 15:08:15 +01:00
public function returnsLatitude(): void
{
$subject = new Address('{"geo": {"latitude": 50.978765}}');
self::assertSame(50.978765, $subject->getLatitute());
}
#[Test]
2021-02-16 15:08:15 +01:00
public function returnsLongitude(): void
{
$subject = new Address('{"geo": {"longitude": 11.029133}}');
self::assertSame(11.029133, $subject->getLongitude());
}
#[Test]
2021-02-16 12:02:10 +01:00
public function returnsSerializedString(): void
{
$subject = new Address('{"street": "Example Street 10"}');
self::assertSame('{"street": "Example Street 10"}', (string)$subject);
2021-02-16 12:02:10 +01:00
}
}