Skip to content

Commit

Permalink
Merge pull request #6 from sagautam5/refactor-test-classes-for-each-e…
Browse files Browse the repository at this point in the history
…ntity

Refactor test classes for each entity
  • Loading branch information
sagautam5 authored Feb 10, 2021
2 parents 0cc5b67 + b6b4e8f commit 08f2c9f
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 100 deletions.
7 changes: 3 additions & 4 deletions tests/Feature/DistrictMunicipalityFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct()
/**
* @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException
*/
public function testGetDistrictsWithMunicipalities()
public function test_getDistrictsWithMunicipalities()
{
$districtsWithMunicipalities = $this->district->getDistrictsWithMunicipalities();

Expand All @@ -40,8 +40,7 @@ public function testGetDistrictsWithMunicipalities()
$this->fail('Failed to get associated municipalities of district');
}
}

if ($correct)
$this->assertTrue(true);

$this->assertTrue($correct);
}
}
5 changes: 2 additions & 3 deletions tests/Feature/MunicipalityCountByCategoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -43,7 +43,6 @@ public function testMunicipalityCountByCategory()
}
}

if($correct)
$this->assertTrue(true);
$this->assertTrue($correct);
}
}
10 changes: 4 additions & 6 deletions tests/Feature/ProvinceDistrictFeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct()
*
* @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException
*/
public function testGetProvincesWithDistricts()
public function test_getProvincesWithDistricts()
{
$provinceWithDistricts = $this->province->getProvincesWithDistricts();

Expand All @@ -45,16 +45,15 @@ public function testGetProvincesWithDistricts()
}
}

if ($correct)
$this->assertTrue(true);
$this->assertTrue($correct);
}

/**
* Check if Districts And Their Municipalities Are Correctly Loaded With Provinces
*
* @throws \Sagautam5\LocalStateNepal\Exceptions\LoadingException
*/
public function testGetProvincesWithDistrictsWithMunicipalities()
public function test_getProvincesWithDistrictsWithMunicipalities()
{
$provinceWithDistrictWithMunicipalities = $this->province->getProvincesWithDistrictsWithMunicipalities();

Expand All @@ -73,7 +72,6 @@ public function testGetProvincesWithDistrictsWithMunicipalities()
}
}

if($correct)
$this->assertTrue(true);
$this->assertTrue($correct);
}
}
20 changes: 9 additions & 11 deletions tests/Unit/CategoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
Expand All @@ -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'];
Expand All @@ -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],
Expand All @@ -165,7 +163,7 @@ public function testRecursiveSearch()
/**
* Test sort by feature on categories
*/
public function testSortBy()
public function test_sortBy()
{
$keys = $this->category->getKeys();

Expand Down
37 changes: 14 additions & 23 deletions tests/Unit/DistrictTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand All @@ -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);

Expand All @@ -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'];
Expand All @@ -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],
Expand All @@ -184,7 +175,7 @@ public function testRecursiveSearch()
/**
* Test sort by feature on districts
*/
public function testSortBy()
public function test_sortBy()
{
$keys = $this->district->getKeys();

Expand Down
Loading

0 comments on commit 08f2c9f

Please sign in to comment.