class DmsConverterTest in Geofield 8
@coversDefaultClass \Drupal\geofield\DmsConverter @group geofield
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\geofield\Unit\DmsConverterTest
Expanded class hierarchy of DmsConverterTest
File
- tests/
src/ Unit/ DmsConverterTest.php, line 13
Namespace
Drupal\Tests\geofield\UnitView source
class DmsConverterTest extends UnitTestCase {
/**
* @covers ::dmsToDecimal
* @covers ::decimalToDms
*
* @dataProvider dataProvider
*/
public function testConverter(DmsPoint $dms, $decimal) {
$result = DmsConverter::dmsToDecimal($dms);
$this
->assertEquals($decimal, $result);
$result = DmsConverter::decimalToDms($decimal[0], $decimal[1]);
$this
->assertEquals($dms, $result);
}
/**
* Data provider for testConverter.
*
* @return array
* A list of equivalent DMS/Decimal coordinates.
*/
public function dataProvider() {
return [
'Simple' => [
new DmsPoint([
'orientation' => 'E',
'degrees' => 40,
'minutes' => 0,
'seconds' => 0,
], [
'orientation' => 'N',
'degrees' => 9,
'minutes' => 0,
'seconds' => 0,
]),
[
40,
9,
],
],
'Negative' => [
new DmsPoint([
'orientation' => 'W',
'degrees' => 40,
'minutes' => 0,
'seconds' => 0,
], [
'orientation' => 'S',
'degrees' => 9,
'minutes' => 0,
'seconds' => 0,
]),
[
-40,
-9,
],
],
'Decimal' => [
new DmsPoint([
'orientation' => 'W',
'degrees' => 3,
'minutes' => 3,
'seconds' => 3,
], [
'orientation' => 'S',
'degrees' => 2,
'minutes' => 2,
'seconds' => 2,
]),
[
-3.0508333333333333,
-2.033888888888889,
],
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DmsConverterTest:: |
public | function | Data provider for testConverter. | |
DmsConverterTest:: |
public | function | @covers ::dmsToDecimal @covers ::decimalToDms | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |