Rename Game and Bootsrap methods to address feedback

This commit is contained in:
Austen McDonald
2016-05-19 22:05:59 -07:00
parent c60794511f
commit ca98a7337a
5 changed files with 26 additions and 26 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ use Doctrine\ORM\Tools\SchemaTool;
class Bootstrap
{
public static function game(): Game
public static function createGame(): Game
{
$pdo = new \PDO($GLOBALS['DB_DSN'], $GLOBALS["DB_USER"], $GLOBALS["DB_PASSWORD"]);
+2 -2
View File
@@ -22,7 +22,7 @@ class Game
* Returns the game's entity manager.
* @return EntityManagerInterface The game's database entity manager.
*/
public function db(): EntityManagerInterface
public function getEntityManager(): EntityManagerInterface
{
return $this->entityManager;
}
@@ -31,7 +31,7 @@ class Game
* Returns the game's event manager.
* @return EventManager The game's event manager.
*/
public function events(): EventManager
public function getEventManager(): EventManager
{
return $this->eventManager;
}
+6 -6
View File
@@ -63,13 +63,13 @@ class ModuleManager
*/
public static function register(Game $g, string $library, PackageInterface $package)
{
$m = $g->db()->getRepository(Module::class)->find($library);
$m = $g->getEntityManager()->getRepository(Module::class)->find($library);
if ($m) {
throw new ModuleAlreadyExistsException($library);
} else {
// TODO: handle error cases here.
$m = new Module($library);
$m->save($g->db());
$m->save($g->getEntityManager());
// Subscribe to the module's events.
$subscriptions = ModuleManager::getPackageSubscriptions($package);
@@ -77,7 +77,7 @@ class ModuleManager
$pattern = $s['pattern'];
$class = $s['class'];
$g->events()->subscribe($pattern, $class);
$g->getEventManager()->subscribe($pattern, $class);
}
}
}
@@ -93,12 +93,12 @@ class ModuleManager
*/
public static function unregister(Game $g, string $library, PackageInterface $package)
{
$m = $g->db()->getRepository(Module::class)->find($library);
$m = $g->getEntityManager()->getRepository(Module::class)->find($library);
if (!$m) {
throw new ModuleDoesNotExistException($library);
} else {
// TODO: handle error cases here.
$m->delete($g->db());
$m->delete($g->getEntityManager());
// Unsubscribe the module's events.
$subscriptions = ModuleManager::getPackageSubscriptions($package);
@@ -107,7 +107,7 @@ class ModuleManager
$class = $s['class'];
try {
$g->events()->unsubscribe($pattern, $class);
$g->getEventManager()->unsubscribe($pattern, $class);
} catch (SubscriptionNotFoundException $e) {
// TODO: log this but continue on.
}
+3 -3
View File
@@ -9,8 +9,8 @@ class BootstrapTest extends \PHPUnit_Framework_TestCase
{
public function testGame()
{
$g = Bootstrap::game();
$this->assertNotNull($g->db());
$this->assertNotNull($g->events());
$g = Bootstrap::createGame();
$this->assertNotNull($g->getEntityManager());
$this->assertNotNull($g->getEventManager());
}
}
+14 -14
View File
@@ -33,7 +33,7 @@ class ModuleManagerTest extends ModelTestCase
$game = $this->getMockBuilder(Game::class)
->disableOriginalConstructor()
->getMock();
$game->method('db')->willReturn($this->getEntityManager());
$game->method('getEntityManager')->willReturn($this->getEntityManager());
$package = $this->getMockBuilder(PackageInterface::class)->getMock();
@@ -62,7 +62,7 @@ class ModuleManagerTest extends ModelTestCase
$game = $this->getMockBuilder(Game::class)
->disableOriginalConstructor()
->getMock();
$game->method('db')->willReturn($this->getEntityManager());
$game->method('getEntityManager')->willReturn($this->getEntityManager());
$mm = new ModuleManager($this->getEntityManager());
@@ -84,8 +84,8 @@ class ModuleManagerTest extends ModelTestCase
$game = $this->getMockBuilder(Game::class)
->disableOriginalConstructor()
->getMock();
$game->method('db')->willReturn($this->getEntityManager());
$game->method('events')->willReturn($eventManager);
$game->method('getEntityManager')->willReturn($this->getEntityManager());
$game->method('getEventManager')->willReturn($eventManager);
$mm = new ModuleManager($this->getEntityManager());
@@ -129,8 +129,8 @@ class ModuleManagerTest extends ModelTestCase
$game = $this->getMockBuilder(Game::class)
->disableOriginalConstructor()
->getMock();
$game->method('db')->willReturn($this->getEntityManager());
$game->method('events')->willReturn($eventManager);
$game->method('getEntityManager')->willReturn($this->getEntityManager());
$game->method('getEventManager')->willReturn($eventManager);
$mm = new ModuleManager($this->getEntityManager());
@@ -173,8 +173,8 @@ class ModuleManagerTest extends ModelTestCase
$game = $this->getMockBuilder(Game::class)
->disableOriginalConstructor()
->getMock();
$game->method('db')->willReturn($this->getEntityManager());
$game->method('events')->willReturn($eventManager);
$game->method('getEntityManager')->willReturn($this->getEntityManager());
$game->method('getEventManager')->willReturn($eventManager);
$mm = new ModuleManager($this->getEntityManager());
@@ -198,8 +198,8 @@ class ModuleManagerTest extends ModelTestCase
$game = $this->getMockBuilder(Game::class)
->disableOriginalConstructor()
->getMock();
$game->method('db')->willReturn($this->getEntityManager());
$game->method('events')->willReturn($eventManager);
$game->method('getEntityManager')->willReturn($this->getEntityManager());
$game->method('getEventManager')->willReturn($eventManager);
$mm = new ModuleManager($this->getEntityManager());
@@ -248,8 +248,8 @@ class ModuleManagerTest extends ModelTestCase
$game = $this->getMockBuilder(Game::class)
->disableOriginalConstructor()
->getMock();
$game->method('db')->willReturn($this->getEntityManager());
$game->method('events')->willReturn($eventManager);
$game->method('getEntityManager')->willReturn($this->getEntityManager());
$game->method('getEventManager')->willReturn($eventManager);
$mm = new ModuleManager($this->getEntityManager());
@@ -297,8 +297,8 @@ class ModuleManagerTest extends ModelTestCase
$game = $this->getMockBuilder(Game::class)
->disableOriginalConstructor()
->getMock();
$game->method('db')->willReturn($this->getEntityManager());
$game->method('events')->willReturn($eventManager);
$game->method('getEntityManager')->willReturn($this->getEntityManager());
$game->method('getEventManager')->willReturn($eventManager);
$mm = new ModuleManager($this->getEntityManager());