Skip to content

Commit

Permalink
Fix tests for Symfony 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hacfi committed Feb 2, 2019
1 parent 5148e97 commit 70bd4d1
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 46 deletions.
8 changes: 4 additions & 4 deletions Tests/EventListener/ReplyToHttpResponseListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function couldBeConstructedWithOneArgument()
public function shouldDoNothingIfExceptionNotInstanceOfReply()
{
$expectedException = new Exception;

$event = new GetResponseForExceptionEvent(
$this->createHttpKernelMock(),
new Request,
Expand All @@ -40,11 +40,11 @@ public function shouldDoNothingIfExceptionNotInstanceOfReply()
->expects($this->never())
->method('convert')
;

$listener = new ReplyToHttpResponseListener($converterMock);

$listener->onKernelException($event);

$this->assertNull($event->getResponse());
$this->assertSame($expectedException, $event->getException());
$this->assertFalse($event->isPropagationStopped());
Expand Down Expand Up @@ -218,4 +218,4 @@ protected function createHttpKernelMock()
{
return $this->createMock('Symfony\Component\HttpKernel\HttpKernelInterface');
}
}
}
5 changes: 2 additions & 3 deletions Tests/Functional/Command/CreateCaptureTokenCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
use Payum\Bundle\PayumBundle\Command\CreateCaptureTokenCommand;
use Payum\Bundle\PayumBundle\Tests\Functional\WebTestCase;
use Payum\Core\Registry\RegistryInterface;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;

class CreateCaptureTokenCommandTest extends WebTestCase
{
Expand Down Expand Up @@ -79,7 +78,7 @@ public function shouldCreateCaptureTokenWithRouteAsAfterUrl()
protected function executeConsole(Command $command, array $arguments = array())
{
$command->setApplication(new Application($this->client->getKernel()));
if ($command instanceof ContainerAwareCommand) {
if ($command instanceof ContainerAwareInterface) {
$command->setContainer($this->client->getContainer());
}

Expand Down
5 changes: 2 additions & 3 deletions Tests/Functional/Command/CreateNotifyTokenCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
use Payum\Bundle\PayumBundle\Command\CreateNotifyTokenCommand;
use Payum\Bundle\PayumBundle\Tests\Functional\WebTestCase;
use Payum\Core\Registry\RegistryInterface;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;

class CreateNotifyTokenCommandTest extends WebTestCase
{
Expand Down Expand Up @@ -62,7 +61,7 @@ public function shouldCreateNotifyTokenWithModel()
protected function executeConsole(Command $command, array $arguments = array())
{
$command->setApplication(new Application($this->client->getKernel()));
if ($command instanceof ContainerAwareCommand) {
if ($command instanceof ContainerAwareInterface) {
$command->setContainer($this->client->getContainer());
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Command/DebugGatewayCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

use Payum\Bundle\PayumBundle\Command\DebugGatewayCommand;
use Payum\Bundle\PayumBundle\Tests\Functional\WebTestCase;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;

class DebugGatewayCommandTest extends WebTestCase
{
Expand Down Expand Up @@ -90,7 +90,7 @@ protected function executeConsole(Command $command, array $arguments = [], array
$command->setApplication(new Application($this->client->getKernel()));
}

if ($command instanceof ContainerAwareCommand) {
if ($command instanceof ContainerAwareInterface) {
$command->setContainer($this->client->getContainer());
}

Expand Down
5 changes: 2 additions & 3 deletions Tests/Functional/Command/StatusCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
use Payum\Bundle\PayumBundle\Command\StatusCommand;
use Payum\Bundle\PayumBundle\Tests\Functional\WebTestCase;
use Payum\Core\Registry\RegistryInterface;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;

class StatusCommandTest extends WebTestCase
{
Expand Down Expand Up @@ -46,7 +45,7 @@ public function shouldReturnNewStatus()
protected function executeConsole(Command $command, array $arguments = array())
{
$command->setApplication(new Application($this->client->getKernel()));
if ($command instanceof ContainerAwareCommand) {
if ($command instanceof ContainerAwareInterface) {
$command->setContainer($this->client->getContainer());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class ReplyToHttpResponseListenerTest extends WebTestCase
*/
public function couldBeGetFromContainerAsService()
{
$listener = $this->container->get('payum.listener.reply_to_http_response');
$listener = static::$container->get('payum.listener.reply_to_http_response');

$this->assertInstanceOf('Payum\Bundle\PayumBundle\EventListener\ReplyToHttpResponseListener', $listener);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function setUp()
{
parent::setUp();

$this->formFactory = $this->container->get('form.factory');
$this->formFactory = static::$container->get('form.factory');
}

/**
Expand Down Expand Up @@ -92,4 +92,4 @@ public function shouldHideDaySelectAndSetDayFromGivenDateTimeAsValue()
$this->assertEquals(array('style' => 'display:none'), $view['day']->vars['attr']);
$this->assertEquals(10, $view['day']->vars['value']);
}
}
}
2 changes: 1 addition & 1 deletion Tests/Functional/Form/Type/CreditCardTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function setUp()
{
parent::setUp();

$this->formFactory = $this->container->get('form.factory');
$this->formFactory = static::$container->get('form.factory');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Tests/Functional/Form/Type/GatewayConfigTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected function setUp()
{
parent::setUp();

$this->formFactory = $this->container->get('form.factory');
$this->formFactory = static::$container->get('form.factory');
}

/**
Expand All @@ -35,4 +35,4 @@ public function couldBeCreatedByFormFactory()
$this->assertInstanceOf(FormInterface::class, $form);
$this->assertInstanceOf(FormView::class, $view);
}
}
}
4 changes: 2 additions & 2 deletions Tests/Functional/Form/Type/GatewayFactoriesChoiceTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function setUp()
{
parent::setUp();

$this->formFactory = $this->container->get('form.factory');
$this->formFactory = static::$container->get('form.factory');
}

/**
Expand All @@ -32,4 +32,4 @@ public function couldBeCreatedByFormFactory()
$this->assertInstanceOf(FormInterface::class, $form);
$this->assertInstanceOf(FormView::class, $view);
}
}
}
14 changes: 7 additions & 7 deletions Tests/Functional/PayumBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,47 +12,47 @@ class PayumBuilderTest extends WebTestCase
public function testCouldBeGetFromContainerAsService()
{
/** @var PayumBuilder $builder */
$builder = $this->container->get('payum.builder');
$builder = static::$container->get('payum.builder');

$this->assertInstanceOf(PayumBuilder::class, $builder);
}

public function testShouldContainCoreGatewayFactoryBuilder()
{
/** @var PayumBuilder $builder */
$builder = $this->container->get('payum.builder');
$builder = static::$container->get('payum.builder');

$this->assertAttributeInstanceOf(CoreGatewayFactoryBuilder::class, 'coreGatewayFactory', $builder);
}

public function testShouldContainHttpRequestVerifierBuilder()
{
/** @var PayumBuilder $builder */
$builder = $this->container->get('payum.builder');
$builder = static::$container->get('payum.builder');

$this->assertAttributeInstanceOf(HttpRequestVerifierBuilder::class, 'httpRequestVerifier', $builder);
}

public function testShouldContainTokenFactoryBuilder()
{
/** @var PayumBuilder $builder */
$builder = $this->container->get('payum.builder');
$builder = static::$container->get('payum.builder');

$this->assertAttributeInstanceOf(TokenFactoryBuilder::class, 'tokenFactory', $builder);
}

public function testShouldContainMainRegistry()
{
/** @var PayumBuilder $builder */
$builder = $this->container->get('payum.builder');
$builder = static::$container->get('payum.builder');

$this->assertAttributeInstanceOf(ContainerAwareRegistry::class, 'mainRegistry', $builder);
}

public function testShouldContainGenericTokenFactoryPaths()
{
/** @var PayumBuilder $builder */
$builder = $this->container->get('payum.builder');
$builder = static::$container->get('payum.builder');

$this->assertAttributeEquals([
'capture' => 'payum_capture_do',
Expand All @@ -63,4 +63,4 @@ public function testShouldContainGenericTokenFactoryPaths()
'payout' => 'payum_payout_do',
], 'genericTokenFactoryPaths', $builder);
}
}
}
22 changes: 11 additions & 11 deletions Tests/Functional/PayumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,23 @@ class PayumTest extends WebTestCase
public function testCouldBeGetFromContainerAsService()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$this->assertInstanceOf(Payum::class, $payum);
}

public function testShouldReturnHttpRequestVerifyRequest()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$this->assertInstanceOf(HttpRequestVerifier::class, $payum->getHttpRequestVerifier());
}

public function testShouldReturnTokenFactory()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$tokenFactory = $payum->getTokenFactory();
$this->assertInstanceOf(GenericTokenFactory::class, $tokenFactory);
Expand All @@ -42,7 +42,7 @@ public function testShouldReturnTokenFactory()
public function testShouldReturnTokenStorage()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$storage = $payum->getTokenStorage();
$this->assertInstanceOf(StorageInterface::class, $storage);
Expand All @@ -51,7 +51,7 @@ public function testShouldReturnTokenStorage()
public function testShouldReturnStorages()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$storages = $payum->getStorages();
$this->assertInternalType('array', $storages);
Expand All @@ -61,7 +61,7 @@ public function testShouldReturnStorages()
public function testShouldReturnGateways()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$gateways = $payum->getGateways();
$this->assertInternalType('array', $gateways);
Expand All @@ -71,7 +71,7 @@ public function testShouldReturnGateways()
public function testShouldReturnGatewaysFactories()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$factories = $payum->getGatewayFactories();
$this->assertInternalType('array', $factories);
Expand All @@ -81,7 +81,7 @@ public function testShouldReturnGatewaysFactories()
public function testShouldReturnGatewayFactory()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$this->assertInstanceOf(PaypalExpressCheckoutGatewayFactory::class, $payum->getGatewayFactory('paypal_express_checkout'));
$this->assertInstanceOf(StripeJsGatewayFactory::class, $payum->getGatewayFactory('stripe_js'));
Expand All @@ -90,7 +90,7 @@ public function testShouldReturnGatewayFactory()
public function testShouldReturnGateway()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$this->assertInstanceOf(GatewayInterface::class, $payum->getGateway('fooGateway'));
$this->assertInstanceOf(GatewayInterface::class, $payum->getGateway('barGateway'));
Expand All @@ -99,8 +99,8 @@ public function testShouldReturnGateway()
public function testShouldReturnStorage()
{
/** @var Payum $payum */
$payum = $this->container->get('payum');
$payum = static::$container->get('payum');

$this->assertInstanceOf(StorageInterface::class, $payum->getStorage(ArrayObject::class));
}
}
}
6 changes: 3 additions & 3 deletions Tests/Functional/WebTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ abstract class WebTestCase extends BaseWebTestCase
/**
* @var ContainerInterface
*/
protected $container;
protected static $container;

protected function setUp()
{
parent::setUp();

$this->client = static::createClient();
$this->container = static::$kernel->getContainer();
static::$container = static::$kernel->getContainer();
}

/**
Expand All @@ -34,4 +34,4 @@ public static function getKernelClass()

return 'AppKernel';
}
}
}
3 changes: 2 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@

<php>
<env name="SHELL_VERBOSITY" value="-1" />
<env name="KERNEL_CLASS" value="App\Kernel" />
</php>
</phpunit>
</phpunit>

0 comments on commit 70bd4d1

Please sign in to comment.