Skip to content

Commit

Permalink
Added tests for Point::toArray() and Countable & Traversable interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed May 14, 2015
1 parent 182795e commit b8ef5c5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/PointTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,35 @@ public function testXyzmEmptyWithSRID()
{
$this->assertPointEmptyFactoryMethod(Point::xyzmEmpty(123), true, true, 123);
}

/**
* @dataProvider providerToArrayAndInterfaces
*
* @param string $point The WKT of the point to test.
* @param array $coordinates The expected coordinates.
*/
public function testToArrayAndInterfaces($point, array $coordinates)
{
$point = Point::fromText($point);
$this->assertSame($coordinates, $point->toArray());
$this->assertSame($coordinates, iterator_to_array($point));
$this->assertSame(count($coordinates), count($point));
}

/**
* @return array
*/
public function providerToArrayAndInterfaces()
{
return [
['POINT EMPTY', []],
['POINT Z EMPTY', []],
['POINT M EMPTY', []],
['POINT ZM EMPTY', []],
['POINT (1.2 2.3)', [1.2, 2.3]],
['POINT Z (2.3 3.4 4.5)', [2.3, 3.4, 4.5]],
['POINT M (3.4 4.5 5.6)', [3.4, 4.5, 5.6]],
['POINT ZM (4.5 5.6 6.7 7.8)', [4.5, 5.6, 6.7, 7.8]],
];
}
}

0 comments on commit b8ef5c5

Please sign in to comment.