diff --git a/.github/workflows/pr-only.yaml b/.github/workflows/pr-only.yaml index d83d6cf..63b0f12 100644 --- a/.github/workflows/pr-only.yaml +++ b/.github/workflows/pr-only.yaml @@ -76,23 +76,23 @@ jobs: run: sudo chmod +x codecov # RUN tests an upload reports ### (Codecov integration - STEP 3) - # - name: Run Service Testsuite with Coverage - # run: vendor/bin/phpunit --testsuite="Services Tests" --coverage-clover=coverage-service.xml + - name: Run Service Testsuite with Coverage + run: vendor/bin/phpunit --testsuite="Services Tests" --coverage-clover=coverage-service.xml - # - name: Upload Service coverage report - # run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'service'-${{ github.run_id }} -F service -f coverage-service.xml + - name: Upload Service coverage report + run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'service'-${{ github.run_id }} -F service -f coverage-service.xml - # - name: Run Controller Testsuite with Coverage - # run: vendor/bin/phpunit --testsuite="Controllers Tests" --coverage-clover=coverage-controller.xml + - name: Run Controller Testsuite with Coverage + run: vendor/bin/phpunit --testsuite="Controllers Tests" --coverage-clover=coverage-controller.xml - # - name: Upload Controller coverage report - # run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'controller'-${{ github.run_id }} -F controller -f coverage-controller.xml + - name: Upload Controller coverage report + run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'controller'-${{ github.run_id }} -F controller -f coverage-controller.xml - # - name: Run Unit Testsuite with Coverage - # run: vendor/bin/phpunit --testsuite="Unit Tests" --coverage-clover=coverage-unit.xml + - name: Run Unit Testsuite with Coverage + run: vendor/bin/phpunit --testsuite="Unit Tests" --coverage-clover=coverage-unit.xml - # - name: Upload unit coverage report - # run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'unit'-${{ github.run_id }} -F unit -f coverage-unit.xml + - name: Upload unit coverage report + run: ./codecov upload-process --disable-search -t ${{ secrets.CODECOV_TOKEN }} -n 'unit'-${{ github.run_id }} -F unit -f coverage-unit.xml - name: Javascript tests using Jest run: npm run test diff --git a/app/Models/Charge.php b/app/Models/Charge.php index a8692ff..6df75b9 100644 --- a/app/Models/Charge.php +++ b/app/Models/Charge.php @@ -58,7 +58,9 @@ public function getDataForReport() } public function uncoveredUnitTestFunction() { - return 'data'; + if (true) { + return 'data'; + } } public function unitTestModel() { diff --git a/app/Models/ImportantOne.php b/app/Models/ImportantOne.php index 7b94123..726342b 100644 --- a/app/Models/ImportantOne.php +++ b/app/Models/ImportantOne.php @@ -3,16 +3,18 @@ namespace App\Models; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Factories\HasFactory; class ImportantOne extends Model { + use HasFactory; public function brandNewFunctionHasNoTest() { - if ( $_COOKIE['codecov'] === '' ) { - return 'we have no cookie'; + if ( is_object($this) ) { + return 'we have data'; } else { - return 'we have cookies'; + return 'we have no data'; } } diff --git a/database/factories/ImportantOneFactory.php b/database/factories/ImportantOneFactory.php new file mode 100644 index 0000000..5a2e73c --- /dev/null +++ b/database/factories/ImportantOneFactory.php @@ -0,0 +1,35 @@ + 99, + 'status' => 'active', + 'created' => now(), + 'created_at' => now(), + 'object' => 'important_row', + 'transaction_id' => Str::random(10), + ]; + } +} diff --git a/tests/Unit/ChargeTest.php b/tests/Unit/ChargeTest.php index ecfb30e..13b2a5e 100644 --- a/tests/Unit/ChargeTest.php +++ b/tests/Unit/ChargeTest.php @@ -42,4 +42,11 @@ public function testReturnDataSet() { $result = $charge->returnDataSet(); $this->assertEquals('data set', $result); } + + public function testUncoveredUnitTestFuction() { + + $charge = Charge::factory()->make(); + $result = $charge->uncoveredUnitTestFunction(); + $this->assertEquals('data', $result); + } } diff --git a/tests/Unit/ImportantOneTest.php b/tests/Unit/ImportantOneTest.php new file mode 100644 index 0000000..e5f9adf --- /dev/null +++ b/tests/Unit/ImportantOneTest.php @@ -0,0 +1,26 @@ +make(); + $result = $importantOne->brandNewFunctionHasNoTest(); + $this->assertEquals('we have data', $result); + } + +}