-
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
18 changed files
with
149 additions
and
69 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
### travis builds | ||
/.Build | ||
/composer.lock | ||
/var | ||
|
||
### eclipse files | ||
.settings | ||
.buildpath | ||
|
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
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
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Service; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2010-2016 Rene Nitzsche ([email protected]) | ||
* (c) 2010-2020 Rene Nitzsche ([email protected]) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
|
@@ -22,23 +25,19 @@ | |
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
tx_rnbase::load('tx_rnbase_util_Misc'); | ||
|
||
/** | ||
* Zentrale Klasse für den Zugriff auf verschiedene Services. | ||
*/ | ||
class tx_t3sportstats_util_ServiceRegistry | ||
class StatsServiceRegistry | ||
{ | ||
/** | ||
* Liefert den Statistik-Service. | ||
* | ||
* @return tx_t3sportstats_srv_Statistics | ||
* @return \tx_t3sportstats_srv_Statistics | ||
*/ | ||
public static function getStatisticService() | ||
public function getStatisticService() | ||
{ | ||
return tx_rnbase_util_Misc::getService('t3sportstats', 'statistics'); | ||
return \tx_rnbase_util_Misc::getService('t3sportstats', 'statistics'); | ||
} | ||
} | ||
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/t3sportstats/util/class.tx_t3sportstats_util_ServiceRegistry.php']) { | ||
include_once $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/t3sportstats/util/class.tx_t3sportstats_util_ServiceRegistry.php']; | ||
} |
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 |
---|---|---|
@@ -1,11 +1,15 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Tests\Service; | ||
|
||
use System25\T3sports\Utility\StatsMatchNoteProvider; | ||
use System25\T3sports\Tests\StatsFixtureUtil; | ||
use System25\T3sports\Service\StatsServiceRegistry; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2008-2010 Rene Nitzsche ([email protected]) | ||
* (c) 2008-2020 Rene Nitzsche ([email protected]) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
|
@@ -25,21 +29,36 @@ | |
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
class tx_t3sportstats_tests_srvPlayerGoalStats_testcase extends tx_phpunit_testcase | ||
class PlayerGoalStatsTest extends \tx_rnbase_tests_BaseTestCase | ||
{ | ||
private $statsService; | ||
|
||
public function setUp() | ||
{ | ||
$this->statsService = new \tx_t3sportstats_srv_Statistics(); | ||
\System25\T3sports\Utility\StatsConfig::registerPlayerStatsSimple('goals', '10,11,12,13'); | ||
\System25\T3sports\Utility\StatsConfig::registerPlayerStatsSimple('assists', '31'); | ||
\System25\T3sports\Utility\StatsConfig::registerPlayerStatsSimple('goalshead', '11'); | ||
\System25\T3sports\Utility\StatsConfig::registerPlayerStatsSimple('goalspenalty', '12'); | ||
\System25\T3sports\Utility\StatsConfig::registerPlayerStatsSimple('goalsown', '30'); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function test_indexPlayerStatsHome() | ||
{ | ||
$matchIdx = 0; | ||
$matches = tx_t3sportstats_tests_Util::getMatches(); | ||
|
||
$matches = StatsFixtureUtil::getMatches(); | ||
$match = $matches[$matchIdx]; | ||
$srv = tx_t3sportstats_util_ServiceRegistry::getStatisticService(); | ||
$bagHash = array(); | ||
$bags = $srv->getPlayerBags($match, true); | ||
$bagHash = []; | ||
|
||
$bags = $this->statsService->getPlayerBags($match, true); | ||
foreach ($bags as $bag) { | ||
$bagHash[$bag->getParentUid()] = $bag; | ||
} | ||
$notes = tx_t3sportstats_tests_Util::getMatchNotes($matchIdx); | ||
$notes = StatsFixtureUtil::getMatchNotes($matchIdx); | ||
|
||
$mnProv = StatsMatchNoteProvider::createInstance($notes); | ||
|
||
|
@@ -59,19 +78,21 @@ public function test_indexPlayerStatsHome() | |
$this->assertEquals(1, $bagHash[110]->getTypeValue('goalsjoker'), 'Goals joker are wrong'); | ||
} | ||
|
||
/** | ||
* @group unit | ||
*/ | ||
public function test_indexPlayerStatsGuest() | ||
{ | ||
$matchIdx = 0; | ||
$matches = tx_t3sportstats_tests_Util::getMatches(); | ||
$matches = StatsFixtureUtil::getMatches(); | ||
|
||
$match = $matches[$matchIdx]; | ||
$srv = tx_t3sportstats_util_ServiceRegistry::getStatisticService(); | ||
$bagHash = array(); | ||
$bags = $srv->getPlayerBags($match, false); | ||
$bagHash = []; | ||
$bags = $this->statsService->getPlayerBags($match, false); | ||
foreach ($bags as $bag) { | ||
$bagHash[$bag->getParentUid()] = $bag; | ||
} | ||
$notes = tx_t3sportstats_tests_Util::getMatchNotes($matchIdx); | ||
$notes = StatsFixtureUtil::getMatchNotes($matchIdx); | ||
|
||
$mnProv = StatsMatchNoteProvider::createInstance($notes); | ||
|
||
|
@@ -83,14 +104,14 @@ public function test_indexPlayerStatsGuest() | |
|
||
public function testGetInstance() | ||
{ | ||
$this->assertTrue(is_object(tx_rnbase_util_Misc::getService('t3sportsPlayerStats', 'goals')), 'Service not registered.'); | ||
$this->assertTrue(is_object(\tx_rnbase_util_Misc::getService('t3sportsPlayerStats', 'goals')), 'Service not registered.'); | ||
} | ||
|
||
/** | ||
* @return tx_t3sportstats_srv_PlayerTimeStats | ||
* @return \tx_t3sportstats_srv_PlayerGoalStats | ||
*/ | ||
private static function getService() | ||
{ | ||
return tx_rnbase::makeInstance('tx_t3sportstats_srv_PlayerGoalStats'); | ||
return \tx_rnbase::makeInstance('tx_t3sportstats_srv_PlayerGoalStats'); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Tests; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2008-2017 Rene Nitzsche ([email protected]) | ||
* (c) 2008-2020 Rene Nitzsche ([email protected]) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
|
@@ -22,34 +25,37 @@ | |
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
require_once tx_rnbase_util_Extensions::extPath('rn_base').'class.tx_rnbase.php'; | ||
|
||
tx_rnbase::load('tx_rnbase_util_Spyc'); | ||
|
||
class tx_t3sportstats_tests_Util | ||
class StatsFixtureUtil | ||
{ | ||
public static function createCompetition($uid, $saison, $agegroup) | ||
{ | ||
return new tx_cfcleague_models_Competition(array('uid' => $uid, 'saison' => $saison, 'agegroup' => $agegroup)); | ||
return new \tx_cfcleague_models_Competition(array('uid' => $uid, 'saison' => $saison, 'agegroup' => $agegroup)); | ||
} | ||
|
||
public static function getMatches() | ||
{ | ||
$data = tx_rnbase_util_Spyc::YAMLLoad(self::getFixturePath('statistics.yaml')); | ||
$data = \tx_rnbase_util_Spyc::YAMLLoad(self::getFixturePath('statistics.yaml')); | ||
$comps = self::makeInstances($data['league_1'], $data['league_1']['clazz']); | ||
|
||
$teamData = $data['league_1']['teams']; | ||
$teams = []; | ||
foreach (self::makeInstances($teamData, $teamData['clazz']) as $team) { | ||
$teams[$team->getUid()] = $team; | ||
} | ||
$data = $data['league_1']['matches']; | ||
$matches = self::makeInstances($data, $data['clazz']); | ||
foreach ($matches as $match) { | ||
/* @var \tx_cfcleague_models_Match $match*/ | ||
$match->setCompetition($comps[0]); | ||
$match->setHome($teams[$match->getProperty('home')]); | ||
$match->setGuest($teams[$match->getProperty('guest')]); | ||
} | ||
|
||
return $matches; | ||
} | ||
|
||
public static function getMatchNotes($matchIdx) | ||
{ | ||
$data = tx_rnbase_util_Spyc::YAMLLoad(self::getFixturePath('statistics.yaml')); | ||
$data = \tx_rnbase_util_Spyc::YAMLLoad(self::getFixturePath('statistics.yaml')); | ||
$data = $data['league_1']['matches'][$matchIdx]['matchnotes']; | ||
$notes = self::makeInstances($data, $data['clazz']); | ||
|
||
|
@@ -59,8 +65,7 @@ public static function getMatchNotes($matchIdx) | |
private static function makeInstances($yamlData, $clazzName) | ||
{ | ||
// Sicherstellen, daß die Klasse geladen wurde | ||
$ret = array(); | ||
tx_rnbase::load($clazzName); | ||
$ret = []; | ||
foreach ($yamlData as $key => $arr) { | ||
if (isset($arr['record']) && is_array($arr['record'])) { | ||
$ret[$key] = new $clazzName($arr['record']); | ||
|
@@ -72,6 +77,6 @@ private static function makeInstances($yamlData, $clazzName) | |
|
||
private static function getFixturePath($filename) | ||
{ | ||
return tx_rnbase_util_Extensions::extPath('t3sportstats').'tests/fixtures/'.$filename; | ||
return \tx_rnbase_util_Extensions::extPath('t3sportstats').'Tests/fixtures/'.$filename; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,14 @@ | ||
<?php | ||
|
||
namespace System25\T3sports\Tests\Utility; | ||
|
||
use System25\T3sports\Utility\StatsMatchNoteProvider; | ||
use System25\T3sports\Tests\StatsFixtureUtil; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* | ||
* (c) 2008-2010 Rene Nitzsche ([email protected]) | ||
* (c) 2008-2020 Rene Nitzsche ([email protected]) | ||
* All rights reserved | ||
* | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
|
@@ -25,12 +28,15 @@ | |
* This copyright notice MUST APPEAR in all copies of the script! | ||
***************************************************************/ | ||
|
||
class tx_t3sportstats_tests_utilMatchNoteProvider_testcase extends tx_phpunit_testcase | ||
class tx_t3sportstats_tests_utilMatchNoteProvider_testcase extends \tx_rnbase_tests_BaseTestCase | ||
{ | ||
/** | ||
* @group unit | ||
*/ | ||
public function test_getMatchNotes4Profile() | ||
{ | ||
$matchIdx = 0; | ||
$notes = tx_t3sportstats_tests_Util::getMatchNotes($matchIdx); | ||
$notes = StatsFixtureUtil::getMatchNotes($matchIdx); | ||
$mnProv = StatsMatchNoteProvider::createInstance($notes); | ||
$notes = $mnProv->getMatchNotes4Profile(100); | ||
$this->assertEquals(3, count($notes), 'Number of notes for player is wrong'); | ||
|
Oops, something went wrong.