phpOMS/tests/Stdlib/Base/AddressTest.php

89 lines
2.4 KiB
PHP

<?php
/**
* Orange Management
*
* PHP Version 7.4
*
* @package tests
* @copyright Dennis Eichhorn
* @license OMS License 1.0
* @version 1.0.0
* @link https://orange-management.org
*/
declare(strict_types=1);
namespace phpOMS\tests\Stdlib\Base;
use phpOMS\Stdlib\Base\Address;
use phpOMS\Stdlib\Base\Location;
/**
* @internal
*/
class AddressTest extends \PHPUnit\Framework\TestCase
{
public function testAttributes() : void
{
$address = new Address();
self::assertObjectHasAttribute('recipient', $address);
self::assertObjectHasAttribute('fao', $address);
self::assertObjectHasAttribute('location', $address);
}
public function testDefault() : void
{
$expected = [
'recipient' => '',
'fao' => '',
'location' => [
'postal' => '',
'city' => '',
'country' => '',
'address' => '',
'state' => '',
'geo' => [
'lat' => 0,
'long' => 0,
],
],
];
$address = new Address();
self::assertEquals('', $address->getRecipient());
self::assertEquals('', $address->getFAO());
self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $address->getLocation());
self::assertEquals($expected, $address->toArray());
self::assertEquals($expected, $address->jsonSerialize());
}
public function testGetSet() : void
{
$expected = [
'recipient' => 'recipient',
'fao' => 'fao',
'location' => [
'postal' => '',
'city' => '',
'country' => '',
'address' => '',
'state' => '',
'geo' => [
'lat' => 0,
'long' => 0,
],
],
];
$address = new Address();
$address->setFAO('fao');
$address->setRecipient('recipient');
$address->setLocation(new Location());
self::assertEquals('recipient', $address->getRecipient());
self::assertEquals('fao', $address->getFAO());
self::assertInstanceOf('\phpOMS\Stdlib\Base\Location', $address->getLocation());
self::assertEquals($expected, $address->toArray());
self::assertEquals($expected, $address->jsonSerialize());
}
}