Skip to content

Commit

Permalink
Improving criteria tests (#81)
Browse files Browse the repository at this point in the history
* WIP humbug

* Unit tests improved by Humbug

* Adding humbug to .gitignore

* Fixes for PHP 5.4 and 5.5

* Testing Coordinates Criteria

* Improving unit tests for NumberCriteria
  • Loading branch information
krzysztof-gzocha authored Jul 30, 2016
1 parent afdd3e6 commit 7aa26d9
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/Criteria/CoordinatesCriteriaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@ public function shouldBeAppliedDataProvider()
];
}

/**
* @param $lat
* @param $lon
* @param $expectedLat
* @param $expectedLon
* @dataProvider gettersAndSettersDataProvider
*/
public function testGettersAndSetters($lat, $lon, $expectedLat, $expectedLon)
{
$model = new CoordinatesCriteria();

$model->setLatitude($lat);
$model->setLongitude($lon);

$this->assertEquals($expectedLat, $model->getLatitude());
$this->assertEquals($expectedLon, $model->getLongitude());
}

public function gettersAndSettersDataProvider()
{
return [
[12.123, 23.233, 12.123, 23.233],
['12.123', '23.233', 12.123, 23.233],
[null, '', 0.0, 0.0],
];
}

public function testIfImplementsInterface()
{
$this->checkIfImplementsInterface(new CoordinatesCriteria());
Expand Down
22 changes: 22 additions & 0 deletions tests/Criteria/NumberCriteriaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,26 @@ public function dataProvider()
[2.123, true],
];
}

/**
* @param $number
* @param $expectedNumber
* @dataProvider gettersAndSettersDataProvider
*/
public function testGettersAndSetters($number, $expectedNumber)
{
$model = new NumberCriteria();
$model->setNumber($number);

$this->assertEquals($expectedNumber, $model->getNumber());
}

public function gettersAndSettersDataProvider()
{
return [
[12.123, 12.123],
['12.123', 12.123],
[null, 0.0],
];
}
}

0 comments on commit 7aa26d9

Please sign in to comment.