From 7aa26d951a234e9f0eb0a1116644c532f216015f Mon Sep 17 00:00:00 2001 From: Krzysztof Gzocha Date: Sat, 30 Jul 2016 14:25:25 +0400 Subject: [PATCH] Improving criteria tests (#81) * 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 --- tests/Criteria/CoordinatesCriteriaTest.php | 27 ++++++++++++++++++++++ tests/Criteria/NumberCriteriaTest.php | 22 ++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/tests/Criteria/CoordinatesCriteriaTest.php b/tests/Criteria/CoordinatesCriteriaTest.php index 05ad6ce..0a8ea43 100644 --- a/tests/Criteria/CoordinatesCriteriaTest.php +++ b/tests/Criteria/CoordinatesCriteriaTest.php @@ -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()); diff --git a/tests/Criteria/NumberCriteriaTest.php b/tests/Criteria/NumberCriteriaTest.php index 5f41649..048acba 100644 --- a/tests/Criteria/NumberCriteriaTest.php +++ b/tests/Criteria/NumberCriteriaTest.php @@ -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], + ]; + } }