address = new Address(); } /** * @covers Modules\Admin\Models\Address * @group module */ public function testDefault() : void { $expected = [ 'postal' => '', 'city' => '', 'country' => 'XX', 'address' => '', 'state' => '', 'geo' => [ 'lat' => 0, 'long' => 0, ], 'name' => '', 'addition' => '', ]; self::assertEquals('', $this->address->name); self::assertEquals('', $this->address->addition); self::assertEquals($expected, $this->address->toArray()); self::assertEquals($expected, $this->address->jsonSerialize()); } public function testToArray() : void { $expected = [ 'postal' => '0123456789', 'city' => 'city', 'country' => 'Country', 'address' => 'Some address here', 'state' => 'This is a state 123', 'geo' => [ 'lat' => 12.1, 'long' => 11.2, ], 'name' => 'name', 'addition' => 'addition', ]; $this->address->name = 'name'; $this->address->addition = 'addition'; $this->address->postal = '0123456789'; $this->address->setType(AddressType::BUSINESS); $this->address->city = 'city'; $this->address->address = 'Some address here'; $this->address->state = 'This is a state 123'; $this->address->setCountry('Country'); $this->address->setGeo(['lat' => 12.1, 'long' => 11.2,]); self::assertEquals($expected, $this->address->toArray()); } public function testJsonSerialize() : void { $expected = [ 'postal' => '0123456789', 'city' => 'city', 'country' => 'Country', 'address' => 'Some address here', 'state' => 'This is a state 123', 'geo' => [ 'lat' => 12.1, 'long' => 11.2, ], 'name' => 'name', 'addition' => 'addition', ]; $this->address->name = 'name'; $this->address->addition = 'addition'; $this->address->postal = '0123456789'; $this->address->setType(AddressType::BUSINESS); $this->address->city = 'city'; $this->address->address = 'Some address here'; $this->address->state = 'This is a state 123'; $this->address->setCountry('Country'); $this->address->setGeo(['lat' => 12.1, 'long' => 11.2,]); self::assertEquals($expected, $this->address->jsonSerialize()); self::assertEquals(\json_encode($this->address->jsonSerialize()), $this->address->serialize()); } public function testUnserialize() : void { $expected = [ 'postal' => '0123456789', 'city' => 'city', 'country' => 'Country', 'address' => 'Some address here', 'state' => 'This is a state 123', 'geo' => [ 'lat' => 12.1, 'long' => 11.2, ], 'name' => 'name', 'addition' => 'addition', ]; $this->address->unserialize(\json_encode($expected)); self::assertEquals(\json_encode($expected), $this->address->serialize()); } }