Skip to content

Commit

Permalink
update code and set phpstan level to 4
Browse files Browse the repository at this point in the history
  • Loading branch information
sagautam5 committed Apr 7, 2024
1 parent d4f56d4 commit d5b5a9e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- name: Run PHPUnit tests
run: vendor/bin/phpunit
- name: Run PhpStan Analyse Code
run: vendor/bin/phpstan analyse --level=3 src tests
run: vendor/bin/phpstan analyse --level=4 src tests
7 changes: 2 additions & 5 deletions tests/Unit/CategoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,12 @@ public function test_findBy_for_each_short_code()

public function test_allCategories_for_null_values()
{
$hasNull = false;
foreach ($this->category->allCategories() as $set) {
if ($hasNull = in_array(null, (array) $set, true)) {
if (in_array(null, (array) $set, true)) {
$this->fail('Category dataset can\'t have null values');
break;
}
}

$this->assertTrue(!$hasNull);
$this->assertTrue(true);
}

public function test_allCategories_for_count()
Expand Down
7 changes: 2 additions & 5 deletions tests/Unit/DistrictTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,13 @@ public function test_allDistricts_for_count()

public function test_allDistricts_for_null_values()
{
$hasNull = false;
foreach ($this->district->allDistricts() as $set) {
if ($hasNull = in_array(null, (array) $set, true)) {
if (in_array(null, (array) $set, true)) {
$this->fail('District dataset can\'t have null values');
break;
}
}

$this->assertTrue(!$hasNull);
$this->assertTrue(true);
}

public function test_district_for_correct_province_id()
Expand All @@ -103,7 +101,6 @@ public function test_district_for_correct_province_id()
if($district && !in_array($district->province_id, range(1,7))){
$correct = false;
$this->fail('Invalid Province for District');
break;
}
}

Expand Down
9 changes: 2 additions & 7 deletions tests/Unit/MunicipalityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,13 @@ public function test_allMunicipalities_count()

public function test_allMunicipalities_for_null_values()
{
$hasNull = false;
foreach ($this->municipality->allMunicipalities() as $set) {
if ($hasNull = in_array(null, (array) $set, true)) {
if (in_array(null, (array) $set, true)) {
$this->fail('Municipality dataset can\'t have null values');
break;
}
}

$this->assertTrue(!$hasNull);
$this->assertTrue(true);
}

public function test_if_municipality_has_wards_in_range_of_5_to_33()
Expand All @@ -114,7 +112,6 @@ public function test_if_municipality_has_wards_in_range_of_5_to_33()
{
$correct = false;
$this->fail('Invalid Wards for Municipality');
break;
}
}

Expand All @@ -132,7 +129,6 @@ public function test_if_municipality_has_correct_category_id()
if($municipality && !in_array($municipality->category_id, range(1,4))){
$correct = false;
$this->fail('Invalid Category for Municipality');
break;
}
}

Expand All @@ -150,7 +146,6 @@ public function test_if_municipality_has_correct_district_id()
if($municipality && !in_array($municipality->district_id, range(1,77))){
$correct = false;
$this->fail('Invalid District for Municipality');
break;
}
}

Expand Down
6 changes: 2 additions & 4 deletions tests/Unit/ProvinceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,13 @@ public function test_allProvinces_count()

public function test_allProvinces_for_null_values()
{
$hasNull = false;
foreach ($this->province->allProvinces() as $set) {
if ($hasNull = in_array(null, (array) $set, true)) {
if (in_array(null, (array) $set, true)) {
$this->fail('Province dataset can\'t have null values');
break;
}
}

$this->assertTrue(!$hasNull);
$this->assertTrue(true);
}

public function test_search()
Expand Down

0 comments on commit d5b5a9e

Please sign in to comment.