Completed
Push — master ( 484b1a...998a69 )
by Jeroen De
03:30
created

AreaDescriptionTest::testGetSQLCondition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Maps\Tests\Semantic\ValueDescriptions;
4
5
use Maps\Semantic\ValueDescriptions\AreaDescription;
6
use Maps\Semantic\ValueDescriptions\CoordinateDescription;
7
use CoordinateValue;
8
use SMW\DataValueFactory;
9
use SMWDataItem;
10
use SMWDIGeoCoord;
11
12
/**
13
 * @covers \Maps\Semantic\ValueDescriptions\AreaDescription
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class AreaDescriptionTest extends \PHPUnit_Framework_TestCase {
19
20
	public function setUp() {
21
		if ( !defined( 'SMW_VERSION' ) ) {
22
			$this->markTestSkipped( 'SMW is not available' );
23
		}
24
	}
25
26
	public function testGetBoundingBox() {
27
		$area = new AreaDescription(
28
			new SMWDIGeoCoord( 0, 0 ),
29
			SMW_CMP_EQ,
30
			'10 km'
31
		);
32
33
		$this->assertEquals(
34
			[
35
				'north' => 0.089932160591873,
36
				'east' => 0.089932160591873,
37
				'south' => -0.089932160591873,
38
				'west' => -0.089932160591873
39
			],
40
			$area->getBoundingBox()
41
		);
42
	}
43
44
	public function testGetSQLCondition() {
45
		$area = new AreaDescription(
46
			new SMWDIGeoCoord( 0, 0 ),
47
			SMW_CMP_EQ,
48
			'10 km'
49
		);
50
51
		$this->assertSame(
52
			'geo_table.lat_field < \'0.089932160591873\' AND geo_table.lat_field > \'-0.089932160591873\' '
53
				. 'AND geo_table.long_field < \'0.089932160591873\' AND geo_table.long_field > \'-0.089932160591873\'',
54
			$area->getSQLCondition( 'geo_table', ['id_field', 'lat_field', 'long_field'], wfGetDB( DB_MASTER ) )
55
		);
56
	}
57
58
}
59