-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
527 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,3 +93,62 @@ jobs: | |
- "8.0" | ||
- "8.1" | ||
- "8.2" | ||
php-unit: | ||
name: "PHP Unit" | ||
|
||
runs-on: "ubuntu-latest" | ||
|
||
needs: ["php-lint", "php-cs-fixer"] | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- | ||
typo3-version: "typo3/minimal:^9.5" | ||
php-version: "7.2" | ||
- | ||
typo3-version: "typo3/minimal:^9.5" | ||
php-version: "7.3" | ||
- | ||
typo3-version: "typo3/minimal:^9.5" | ||
php-version: "7.4" | ||
- | ||
typo3-version: "typo3/minimal:^10.4" | ||
php-version: "7.2" | ||
- | ||
typo3-version: "typo3/minimal:^10.4" | ||
php-version: "7.3" | ||
- | ||
typo3-version: "typo3/minimal:^10.4" | ||
php-version: "7.4" | ||
|
||
steps: | ||
- | ||
name: "Checkout" | ||
uses: "actions/checkout@v2" | ||
- | ||
name: "Setup PHP" | ||
uses: "shivammathur/setup-php@v2" | ||
with: | ||
php-version: "${{ matrix.php-version }}" | ||
extensions: "${{ env.PHP_EXTENSIONS }}" | ||
- | ||
name: "Determine composer cache directory" | ||
id: "determine-composer-cache-directory" | ||
run: "echo \"::set-output name=directory::$(composer config cache-dir)\"" | ||
- | ||
name: "Cache dependencies installed with composer" | ||
uses: "actions/[email protected]" | ||
with: | ||
path: "${{ steps.determine-composer-cache-directory.outputs.directory }}" | ||
key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}" | ||
restore-keys: "php-${{ matrix.php-version }}-composer-" | ||
- | ||
name: "Install composer dependencies" | ||
run: | | ||
composer remove --no-update typo3/cms typo3/cms-core | ||
composer require "${{ matrix.typo3-version }}" | ||
- | ||
name: "Run PHP unit tests" | ||
run: "composer test:phpunit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Tests\Series\Rule; | ||
|
||
use PHPUnit\Framework\Assert; | ||
use Sys25\RnBase\Testing\BaseTestCase; | ||
use System25\T3sports\Model\Fixture; | ||
use System25\T3sports\Series\Rule\LostRule; | ||
use System25\T3sports\Series\SeriesRuleInterface; | ||
use System25\T3sports\Tests\StatsFixtureUtil; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2008-2024 Rene Nitzsche ([email protected]) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
class LostTest extends BaseTestCase | ||
{ | ||
/** @var SeriesRuleInterface */ | ||
private $rule; | ||
/** @var Fixture[] */ | ||
private $winsHome; | ||
/** @var Fixture[] */ | ||
private $winsAway; | ||
/** @var Fixture[] */ | ||
private $draws; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->rule = new LostRule(); | ||
$fixtures = StatsFixtureUtil::getMatches(); | ||
$this->winsHome = array_filter($fixtures, function (Fixture $f) { return $f->getGoalsHome() > $f->getGoalsGuest(); }); | ||
$this->winsAway = array_filter($fixtures, function (Fixture $f) { return $f->getGoalsHome() < $f->getGoalsGuest(); }); | ||
$this->draws = array_filter($fixtures, function (Fixture $f) { return $f->getGoalsHome() == $f->getGoalsGuest(); }); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testIsSatisfiedWinHome() | ||
{ | ||
$this->testIsSatisfied($this->winsHome, true, false); | ||
$this->testIsSatisfied($this->winsHome, false, true); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testIsSatisfiedWinAway() | ||
{ | ||
$this->testIsSatisfied($this->winsAway, true, true); | ||
$this->testIsSatisfied($this->winsAway, false, false); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testIsSatisfiedDraw() | ||
{ | ||
$this->testIsSatisfied($this->draws, true, false); | ||
$this->testIsSatisfied($this->draws, false, false); | ||
} | ||
|
||
private function testIsSatisfied(array $fixtures, $isHome, bool $expected) | ||
{ | ||
$config = ''; | ||
foreach ($fixtures as $fixture) { | ||
$result = $this->rule->isSatified($fixture, $isHome, $config); | ||
Assert::assertEquals($expected, $result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Tests\Series\Rule; | ||
|
||
use PHPUnit\Framework\Assert; | ||
use Sys25\RnBase\Testing\BaseTestCase; | ||
use System25\T3sports\Model\Fixture; | ||
use System25\T3sports\Series\Rule\NotLostRule; | ||
use System25\T3sports\Series\SeriesRuleInterface; | ||
use System25\T3sports\Tests\StatsFixtureUtil; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2008-2024 Rene Nitzsche ([email protected]) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
class NotLostTest extends BaseTestCase | ||
{ | ||
/** @var SeriesRuleInterface */ | ||
private $rule; | ||
/** @var Fixture[] */ | ||
private $winsHome; | ||
/** @var Fixture[] */ | ||
private $winsAway; | ||
/** @var Fixture[] */ | ||
private $draws; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->rule = new NotLostRule(); | ||
$fixtures = StatsFixtureUtil::getMatches(); | ||
$this->winsHome = array_filter($fixtures, function (Fixture $f) { return $f->getGoalsHome() > $f->getGoalsGuest(); }); | ||
$this->winsAway = array_filter($fixtures, function (Fixture $f) { return $f->getGoalsHome() < $f->getGoalsGuest(); }); | ||
$this->draws = array_filter($fixtures, function (Fixture $f) { return $f->getGoalsHome() == $f->getGoalsGuest(); }); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testIsSatisfiedWinHome() | ||
{ | ||
$this->testIsSatisfied($this->winsHome, true, true); | ||
$this->testIsSatisfied($this->winsHome, false, false); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testIsSatisfiedWinAway() | ||
{ | ||
$this->testIsSatisfied($this->winsAway, true, false); | ||
$this->testIsSatisfied($this->winsAway, false, true); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testIsSatisfiedDraw() | ||
{ | ||
$this->testIsSatisfied($this->draws, true, true); | ||
$this->testIsSatisfied($this->draws, false, true); | ||
} | ||
|
||
private function testIsSatisfied(array $fixtures, $isHome, bool $expected) | ||
{ | ||
$config = ''; | ||
foreach ($fixtures as $fixture) { | ||
$result = $this->rule->isSatified($fixture, $isHome, $config); | ||
Assert::assertEquals($expected, $result); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Tests\Series\Rule; | ||
|
||
use PHPUnit\Framework\Assert; | ||
use Sys25\RnBase\Testing\BaseTestCase; | ||
use System25\T3sports\Model\Fixture; | ||
use System25\T3sports\Series\Rule\NotWonRule; | ||
use System25\T3sports\Series\SeriesRuleInterface; | ||
use System25\T3sports\Tests\StatsFixtureUtil; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2008-2024 Rene Nitzsche ([email protected]) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
class NotWonTest extends BaseTestCase | ||
{ | ||
/** @var SeriesRuleInterface */ | ||
private $rule; | ||
/** @var Fixture[] */ | ||
private $winsHome; | ||
/** @var Fixture[] */ | ||
private $winsAway; | ||
/** @var Fixture[] */ | ||
private $draws; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->rule = new NotWonRule(); | ||
$fixtures = StatsFixtureUtil::getMatches(); | ||
$this->winsHome = array_filter($fixtures, function (Fixture $f) { return $f->getGoalsHome() > $f->getGoalsGuest(); }); | ||
$this->winsAway = array_filter($fixtures, function (Fixture $f) { return $f->getGoalsHome() < $f->getGoalsGuest(); }); | ||
$this->draws = array_filter($fixtures, function (Fixture $f) { return $f->getGoalsHome() == $f->getGoalsGuest(); }); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testIsSatisfiedWinHome() | ||
{ | ||
$this->testIsSatisfied($this->winsHome, true, false); | ||
$this->testIsSatisfied($this->winsHome, false, true); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testIsSatisfiedWinAway() | ||
{ | ||
$this->testIsSatisfied($this->winsAway, true, true); | ||
$this->testIsSatisfied($this->winsAway, false, false); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function testIsSatisfiedDraw() | ||
{ | ||
$this->testIsSatisfied($this->draws, true, true); | ||
$this->testIsSatisfied($this->draws, false, true); | ||
} | ||
|
||
private function testIsSatisfied(array $fixtures, $isHome, bool $expected) | ||
{ | ||
$config = ''; | ||
foreach ($fixtures as $fixture) { | ||
$result = $this->rule->isSatified($fixture, $isHome, $config); | ||
Assert::assertEquals($expected, $result); | ||
} | ||
} | ||
} |
Oops, something went wrong.