Skip to content
This repository has been archived by the owner on Nov 2, 2024. It is now read-only.

Commit

Permalink
#107 - Improved GridBuilder test to work without requiring the contai…
Browse files Browse the repository at this point in the history
…ner, debrecated old TestCore.
  • Loading branch information
oliverde8 committed Dec 14, 2017
1 parent 89d1612 commit 9f2ca4c
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
use eXpansion\Framework\Core\Model\Gui\Grid\GridBuilderFactory;
use eXpansion\Framework\Core\Model\Gui\ManialinkFactoryInterface;
use eXpansion\Framework\Core\Model\Gui\ManialinkInterface;
use eXpansion\Framework\Core\Plugins\Gui\WindowFactory;
use eXpansion\Framework\Core\Model\UserGroups\Group;
use eXpansion\Framework\Core\Services\Application\DispatcherInterface;
use FML\Controls\Label;
use Tests\eXpansion\Framework\Core\TestCore;
use Tests\eXpansion\Framework\Core\SimpleTestCore;

class GridBuilderTest extends TestCore
class GridBuilderTest extends SimpleTestCore
{
/** @var \PHPUnit_Framework_MockObject_MockObject */
protected $dataCollection;
Expand All @@ -26,10 +27,13 @@ protected function setUp()
{
parent::setUp();

$dispatcher = $this->getMockBuilder(DispatcherInterface::class)
->getMock();

$this->dataCollection = $this->createMock(DataCollectionInterface::class);
$this->manialink = $this->createMock(ManialinkInterface::class);
$this->manialink->method('getUserGroup')->willReturn(
$this->container->get('expansion.framework.core.user_groups.all_players')
new Group(null, $dispatcher)
);
$this->mlFactory = $this->createMock(ManialinkFactoryInterface::class);
}
Expand Down
62 changes: 62 additions & 0 deletions tests/eXpansion/Framework/Core/SimpleTestCore.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

namespace Tests\eXpansion\Framework\Core;

use eXpansion\Framework\GameManiaplanet\DataProviders\ChatDataProvider;
use eXpansion\Framework\GameManiaplanet\DataProviders\Listener\ListenerInterfaceMpLegacyChat;
use eXpansion\Framework\Core\Helpers\ChatOutput;
use eXpansion\Framework\Core\Services\Console;
use eXpansion\Framework\Core\Storage\Data\Player;
use eXpansion\Framework\Core\Storage\PlayerStorage;
use Maniaplanet\DedicatedServer\Xmlrpc\FaultException;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class SimpleTestCore extends KernelTestCase
{
/** @var ContainerInterface */
protected $container;

/** @var Application */
protected $consoleApplication;

/**
* @inheritdoc
*/
protected function setUp()
{
parent::setUp();

// Loading this to force composer autoload to load all possible eXceptions.
new FaultException('test');

//start the symfony kernel
$kernel = static::createKernel();
$kernel->boot();

$this->container = $kernel->getContainer();

$this->consoleApplication = new Application($kernel);
}

protected function getMockPlayerStorage($player)
{
$playerStorage = $this->getMockBuilder(PlayerStorage::class)
->disableOriginalConstructor()
->getMock();
$playerStorage->method('getPlayerInfo')
->willReturn($player);

return $playerStorage;
}

/**
* @return ChatOutput|object
*/
protected function getChatOutputHelper()
{
return $this->container->get(ChatOutput::class);
}
}
6 changes: 6 additions & 0 deletions tests/eXpansion/Framework/Core/TestCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Class TestCore
* @package Tests\eXpansion\Framework\Core
*
* @deprecated
*/
class TestCore extends KernelTestCase
{
/** @var ContainerInterface */
Expand Down

0 comments on commit 9f2ca4c

Please sign in to comment.