forked from geocoder-php/BazingaGeocoderBundle
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttributeDriverTest.php
More file actions
93 lines (75 loc) · 2.28 KB
/
Copy pathAttributeDriverTest.php
File metadata and controls
93 lines (75 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
declare(strict_types=1);
/*
* This file is part of the BazingaGeocoderBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Bazinga\GeocoderBundle\Tests\Mapping\Driver;
use Bazinga\GeocoderBundle\Mapping\Annotations\Address;
use Bazinga\GeocoderBundle\Mapping\Annotations\Geocodeable;
use Bazinga\GeocoderBundle\Mapping\Annotations\Latitude;
use Bazinga\GeocoderBundle\Mapping\Annotations\Longitude;
use Bazinga\GeocoderBundle\Mapping\Driver\AttributeDriver;
use Bazinga\GeocoderBundle\Mapping\Exception\MappingException;
use Doctrine\Common\Annotations\Reader;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\PhpUnit\SetUpTearDownTrait;
/**
* @author Pierre du Plessis <pdples@gmail.com>
*/
final class AttributeDriverTest extends TestCase
{
use SetUpTearDownTrait;
/**
* @var AttributeDriver
*/
private $driver;
/**
* @var Reader
*/
private $reader;
public static function doSetUpBeforeClass(): void
{
if (PHP_VERSION_ID < 80000) {
self::markTestSkipped(sprintf('"%s" is only supported on PHP 8', AttributeDriver::class));
}
}
protected function doSetUp(): void
{
$this->driver = new AttributeDriver();
}
public function testLoadMetadata()
{
$obj = new Dummy3();
$metadata = $this->driver->loadMetadataFromObject($obj);
$this->assertInstanceOf('ReflectionProperty', $metadata->addressProperty);
$this->assertInstanceOf('ReflectionProperty', $metadata->latitudeProperty);
$this->assertInstanceOf('ReflectionProperty', $metadata->longitudeProperty);
}
public function testLoadMetadataFromWrongObject()
{
$this->expectException(MappingException::class);
$this->expectExceptionMessage('The class '.Dummy4::class.' is not geocodeable');
$this->driver->loadMetadataFromObject(new Dummy4());
}
public function testIsGeocodable()
{
$this->assertTrue($this->driver->isGeocodeable(new Dummy3()));
}
}
#[Geocodeable()]
class Dummy3
{
#[Latitude()]
public $latitude;
#[Longitude()]
public $longitude;
#[Address()]
public $address;
}
class Dummy4
{
}