diff --git a/tests/Feature/DistrictMunicipalityFeatureTest.php b/tests/Feature/DistrictMunicipalityFeatureTest.php index 1e44af6..b4d07d3 100644 --- a/tests/Feature/DistrictMunicipalityFeatureTest.php +++ b/tests/Feature/DistrictMunicipalityFeatureTest.php @@ -29,7 +29,7 @@ public function __construct() /** * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testGetDistrictsWithMunicipalities() + public function test_getDistrictsWithMunicipalities() { $districtsWithMunicipalities = $this->district->getDistrictsWithMunicipalities(); @@ -40,8 +40,7 @@ public function testGetDistrictsWithMunicipalities() $this->fail('Failed to get associated municipalities of district'); } } - - if ($correct) - $this->assertTrue(true); + + $this->assertTrue($correct); } } diff --git a/tests/Feature/MunicipalityCountByCategoryTest.php b/tests/Feature/MunicipalityCountByCategoryTest.php index a654f01..6544c7e 100644 --- a/tests/Feature/MunicipalityCountByCategoryTest.php +++ b/tests/Feature/MunicipalityCountByCategoryTest.php @@ -28,7 +28,7 @@ public function __construct() /** * Test Municipalities Count for Each Category */ - public function testMunicipalityCountByCategory() + public function test_municipalityCountByCategory() { $categoryIdSet = range(1,4); $categoryCountSet = [6,11,276,460]; @@ -43,7 +43,6 @@ public function testMunicipalityCountByCategory() } } - if($correct) - $this->assertTrue(true); + $this->assertTrue($correct); } } diff --git a/tests/Feature/ProvinceDistrictFeatureTest.php b/tests/Feature/ProvinceDistrictFeatureTest.php index 3aac597..4ef72d1 100644 --- a/tests/Feature/ProvinceDistrictFeatureTest.php +++ b/tests/Feature/ProvinceDistrictFeatureTest.php @@ -33,7 +33,7 @@ public function __construct() * * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testGetProvincesWithDistricts() + public function test_getProvincesWithDistricts() { $provinceWithDistricts = $this->province->getProvincesWithDistricts(); @@ -45,8 +45,7 @@ public function testGetProvincesWithDistricts() } } - if ($correct) - $this->assertTrue(true); + $this->assertTrue($correct); } /** @@ -54,7 +53,7 @@ public function testGetProvincesWithDistricts() * * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testGetProvincesWithDistrictsWithMunicipalities() + public function test_getProvincesWithDistrictsWithMunicipalities() { $provinceWithDistrictWithMunicipalities = $this->province->getProvincesWithDistrictsWithMunicipalities(); @@ -73,7 +72,6 @@ public function testGetProvincesWithDistrictsWithMunicipalities() } } - if($correct) - $this->assertTrue(true); + $this->assertTrue($correct); } } diff --git a/tests/Unit/CategoryTest.php b/tests/Unit/CategoryTest.php index 9610389..e9b4b25 100644 --- a/tests/Unit/CategoryTest.php +++ b/tests/Unit/CategoryTest.php @@ -31,7 +31,7 @@ public function __construct() /** * Test Category Find By ID */ - public function testFind() + public function test_find_Category_For_Range_Between_1_to_4() { $correctIdSet = range(1,4); $incorrectIdSet = range(5,8); @@ -61,7 +61,7 @@ public function testFind() /** * Test Find Category By Short Code */ - public function testFindByShortCode() + public function test_findBy_For_Each_Short_Code() { $correctCodeSet = ['MC', 'SMC', 'M', 'RM']; $incorrectCodeSet = ['AA', 'BB', 'CC', 'DD']; @@ -90,7 +90,7 @@ public function testFindByShortCode() /** * Test Null Values in Category Data */ - public function testNullValues() + public function test_Null_Values() { $hasNull = false; foreach ($this->category->allCategories() as $set) { @@ -99,16 +99,14 @@ public function testNullValues() break; } } - if(!$hasNull) - $this->assertTrue(true); + + $this->assertTrue(!$hasNull); } /** * Test Number of All Categories - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testAllProvinces() + public function test_allCategories_For_Count() { if(count($this->category->allCategories()) == 4){ $this->assertTrue(true); @@ -120,7 +118,7 @@ public function testAllProvinces() /** * Test Category Search */ - public function testSearch() + public function test_search() { $categories = $this->category->allCategories(); $keywords = ['id', 'name', 'short_code']; @@ -142,7 +140,7 @@ public function testSearch() /** * Test Recursive Search */ - public function testRecursiveSearch() + public function test_recursiveSearch() { $params = $_ENV['APP_LANG'] == 'en' ? [ ['key' => 'name', 'value' => 'Municipality', 'exact' => false], @@ -165,7 +163,7 @@ public function testRecursiveSearch() /** * Test sort by feature on categories */ - public function testSortBy() + public function test_sortBy() { $keys = $this->category->getKeys(); diff --git a/tests/Unit/DistrictTest.php b/tests/Unit/DistrictTest.php index 780d994..e47723c 100644 --- a/tests/Unit/DistrictTest.php +++ b/tests/Unit/DistrictTest.php @@ -30,21 +30,17 @@ public function __construct() /** * Test Largest District - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testLargest() + public function test_largest_District() { $largest = $this->district->largest(); - ($largest->id == 61 && $largest->province_id == 6) ? $this->assertTrue(true): $this->fail('Not a Largest District'); + $this->assertSame([61,6],[$largest->id, $largest->province_id]); } /** * Test Find District By ID - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testFind() + public function test_find_For_Range_Between_1_to_77() { $correctIdSet = range(1,77); $incorrectIdSet = range(78,154); @@ -73,21 +69,17 @@ public function testFind() /** * Test Smallest District - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testSmallest() + public function test_smallest_district() { $smallest = $this->district->smallest(); - ($smallest->id == 23 && $smallest->province_id == 3) ? $this->assertTrue(true): $this->fail('Not a Smallest District'); + $this->assertSame([23,3], [$smallest->id, $smallest->province_id]); } /** * Test Number of All Districts - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testAllDistricts() + public function test_allDistricts_For_Count() { if(count($this->district->allDistricts()) == 77){ $this->assertTrue(true); @@ -99,7 +91,7 @@ public function testAllDistricts() /** * Test Null Values in District Data */ - public function testNullValues() + public function test_Null_Values() { $hasNull = false; foreach ($this->district->allDistricts() as $set) { @@ -108,14 +100,14 @@ public function testNullValues() break; } } - if(!$hasNull) - $this->assertTrue(true); + + $this->assertTrue(!$hasNull); } /** * Test Province of District */ - public function testDistrictProvince() + public function test_District_For_Correct_Province_ID() { $idSet = range(1,77); @@ -130,15 +122,14 @@ public function testDistrictProvince() } } - if($correct) - $this->assertTrue(true); + $this->assertTrue($correct); } /** * Test District Search */ - public function testSearch() + public function test_search() { $districts = $this->district->allDistricts(); $keywords = ['id', 'province_id', 'name', 'area_sq_km', 'website', 'headquarter']; @@ -160,7 +151,7 @@ public function testSearch() /** * Test Recursive Search */ - public function testRecursiveSearch() + public function test_recursiveSearch() { $params = $_ENV['APP_LANG'] == 'en' ? [ ['key' => 'name', 'value' => 'Gulmi', 'exact' => false], @@ -184,7 +175,7 @@ public function testRecursiveSearch() /** * Test sort by feature on districts */ - public function testSortBy() + public function test_sortBy() { $keys = $this->district->getKeys(); diff --git a/tests/Unit/MunicipalityTest.php b/tests/Unit/MunicipalityTest.php index 9fb5e2f..779ea56 100644 --- a/tests/Unit/MunicipalityTest.php +++ b/tests/Unit/MunicipalityTest.php @@ -31,21 +31,18 @@ public function __construct() /** * Test Largest Province - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testLargest() + public function test_largest_Municipality() { $largest = $this->municipality->largest(); - $largest->id == 617 && $largest->district_id==62 && $largest->category_id == 4 ? $this->assertTrue(true): $this->fail('Not a Largest Municipality'); + + $this->assertSame([617,62,4],[$largest->id, $largest->district_id, $largest->category_id]); } /** * Test Find Municipality By ID - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testFind() + public function test_find_for_range_between_1_and_753() { $correctIdSet = range(1,753); $incorrectIdSet = range(754,1000); @@ -74,21 +71,17 @@ public function testFind() /** * Test Smallest Municipality - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testSmallest() + public function test_smallest_Municipality() { $smallest = $this->municipality->smallest(); - ($smallest->id == 274 && $smallest->district_id == 23 && $smallest->category_id == 3) ? $this->assertTrue(true): $this->fail('Not a Smallest Municipality'); + $this->assertSame([274,23,3],[$smallest->id, $smallest->district_id, $smallest->category_id]); } /** * Test Number of All Municipalities - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testAllProvinces() + public function test_All_Municipalities_Count() { if(count($this->municipality->allMunicipalities()) == 753){ $this->assertTrue(true); @@ -100,7 +93,7 @@ public function testAllProvinces() /** * Test Null Values in Municipality Data */ - public function testNullValues() + public function test_Null_Values() { $hasNull = false; foreach ($this->municipality->allMunicipalities() as $set) { @@ -109,14 +102,14 @@ public function testNullValues() break; } } - if(!$hasNull) - $this->assertTrue(true); + + $this->assertTrue(!$hasNull); } /** * Test Municipality Wards */ - public function testMunicipalityWards() + public function test_If_Municipality_Has_Wards_In_Range_Of_5_To_33() { $lang = $this->municipality->getLanguage(); if($lang == 'np'){ @@ -140,14 +133,13 @@ public function testMunicipalityWards() } } - if($correct) - $this->assertTrue(true); + $this->assertTrue($correct); } /** * Test Municipality Categories */ - public function testMunicipalityCategories() + public function test_If_Municipality_Has_Correct_Category_ID() { $idSet = range(1,753); @@ -162,14 +154,13 @@ public function testMunicipalityCategories() } } - if($correct) - $this->assertTrue(true); + $this->assertTrue($correct); } /** - * Test Municipality Categories + * Test Municipality District */ - public function testMunicipalityDistrict() + public function test_If_Municipality_Has_Correct_District_ID() { $idSet = range(1,753); @@ -184,14 +175,13 @@ public function testMunicipalityDistrict() } } - if($correct) - $this->assertTrue(true); + $this->assertTrue($correct); } /** * Test Municipality Search */ - public function testSearch() + public function test_search() { $municipalities = $this->municipality->allMunicipalities(); $keywords = ['id', 'district_id', 'category_id', 'name', 'area_sq_km', 'website', 'wards']; @@ -214,7 +204,7 @@ public function testSearch() /** * Test Recursive Search */ - public function testRecursiveSearch() + public function test_recursiveSearch() { $params = $_ENV['APP_LANG'] == 'en' ? [ ['key' => 'name', 'value' => 'Jorpati', 'exact' => false], @@ -234,7 +224,7 @@ public function testRecursiveSearch() /** * Test sort by feature on municipalities */ - public function testSortBy() + public function test_sortBy() { $keys = $this->municipality->getKeys(); @@ -258,7 +248,7 @@ public function testSortBy() /** * Individual Province Municipality Count Test */ - public function test_GetMunicipalityByProvince_For_Individual_Correct_Count() + public function test_getMunicipalityByProvince_For_Individual_Correct_Count() { $expectedSet = array( '1' => 137, @@ -282,12 +272,13 @@ public function test_GetMunicipalityByProvince_For_Individual_Correct_Count() /** * Total Municipality Count Test */ - public function test_GetMunicipalityByProvince_For_Total_Count() + public function test_getMunicipalityByProvince_For_Total_Count() { $expectedTotal = 753; $actualTotal = 0; - for ($index = 1; $index<=7; $index++){ + for ($index = 1; $index<=7; $index++) + { $actualTotal += count($this->municipality->getMunicipalityByProvince($index)); } diff --git a/tests/Unit/ProvinceTest.php b/tests/Unit/ProvinceTest.php index e4499e9..8f971ca 100644 --- a/tests/Unit/ProvinceTest.php +++ b/tests/Unit/ProvinceTest.php @@ -31,21 +31,17 @@ public function __construct() /** * Test Largest Province - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testLargest() + public function test_largest_Province() { $largest = $this->province->largest(); - $largest->id == 6 ? $this->assertTrue(true): $this->fail('Not a Largest Province'); + $this->assertSame($largest->id, 6); } /** * Test Find Province By ID - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testFind() + public function test_find_Province_For_Range_Between_1_to_7() { $correctIdSet = range(1,7); $incorrectIdSet = range(8,15); @@ -74,21 +70,17 @@ public function testFind() /** * Test Smallest Province - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testSmallest() + public function test_smallest_Province() { $smallest = $this->province->smallest(); - $smallest->id == 2 ? $this->assertTrue(true): $this->fail('Not a Smallest Province'); + $this->assertSame($smallest->id, 2); } /** * Test Number of All Provinces - * - * @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException */ - public function testAllProvinces() + public function test_allProvinces_Count() { if(count($this->province->allProvinces()) == 7){ $this->assertTrue(true); @@ -100,7 +92,7 @@ public function testAllProvinces() /** * Test Null Values in Provinces Data */ - public function testNullValues() + public function test_Null_Values() { $hasNull = false; foreach ($this->province->allProvinces() as $set) { @@ -109,14 +101,14 @@ public function testNullValues() break; } } - if(!$hasNull) - $this->assertTrue(true); + + $this->assertTrue(!$hasNull); } /** * Test Province Search */ - public function testSearch() + public function test_search() { $provinces = $this->province->allProvinces(); $keywords = ['id', 'name', 'area_sq_km', 'website', 'headquarter']; @@ -138,7 +130,7 @@ public function testSearch() /** * Test Recursive Search */ - public function testRecursiveSearch() + public function test_recursiveSearch() { $params = $_ENV['APP_LANG'] == 'en' ? [ ['key' => 'name', 'value' => 'mati', 'exact' => false], @@ -160,7 +152,7 @@ public function testRecursiveSearch() /** * Test sort by feature on province */ - public function testSortBy() + public function test_sortBy() { $keys = $this->province->getKeys();