Skip to content

Commit

Permalink
Merge pull request #487 from hacfi/symfony-4.2
Browse files Browse the repository at this point in the history
Fix Symfony 4.2 deprecations
  • Loading branch information
makasim authored Feb 4, 2019
2 parents 26c4ca3 + 70bd4d1 commit 9669e1c
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 59 deletions.
11 changes: 7 additions & 4 deletions Command/CreateCaptureTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@

use Payum\Core\Exception\RuntimeException;
use Payum\Core\Payum;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class CreateCaptureTokenCommand extends ContainerAwareCommand
class CreateCaptureTokenCommand extends Command implements ContainerAwareInterface
{
use ContainerAwareTrait;

protected static $defaultName = 'payum:security:create-capture-token';

/**
Expand All @@ -35,7 +39,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
$gatewayName = $input->getArgument('gateway-name');
$modelClass = $input->getOption('model-class');
$modelId = $input->getOption('model-id');
$model = null;
$afterUrl = $input->getOption('after-url');

$model = null;
Expand All @@ -62,6 +65,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
protected function getPayum()
{
return $this->getContainer()->get('payum');
return $this->container->get('payum');
}
}
10 changes: 7 additions & 3 deletions Command/CreateNotifyTokenCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@

use Payum\Core\Exception\RuntimeException;
use Payum\Core\Payum;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class CreateNotifyTokenCommand extends ContainerAwareCommand
class CreateNotifyTokenCommand extends Command implements ContainerAwareInterface
{
use ContainerAwareTrait;

protected static $defaultName = 'payum:security:create-notify-token';

/**
Expand Down Expand Up @@ -58,6 +62,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
protected function getPayum()
{
return $this->getContainer()->get('payum');
return $this->container->get('payum');
}
}
10 changes: 7 additions & 3 deletions Command/DebugGatewayCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
use Payum\Core\Gateway;
use Payum\Core\Registry\RegistryInterface;
use Payum\Core\Storage\AbstractStorage;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class DebugGatewayCommand extends ContainerAwareCommand
class DebugGatewayCommand extends Command implements ContainerAwareInterface
{
use ContainerAwareTrait;

protected static $defaultName = 'debug:payum:gateway';

/**
Expand Down Expand Up @@ -141,7 +145,7 @@ protected function getMethodCode(\ReflectionMethod $reflectionMethod)
*/
protected function getPayum()
{
return $this->getContainer()->get('payum');
return $this->container->get('payum');
}

private function findProperGatewayName(InputInterface $input, OutputInterface $output, $gateways, $name)
Expand Down
10 changes: 7 additions & 3 deletions Command/StatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
use Payum\Core\Exception\RuntimeException;
use Payum\Core\Registry\RegistryInterface;
use Payum\Core\Request\GetHumanStatus;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class StatusCommand extends ContainerAwareCommand
class StatusCommand extends Command implements ContainerAwareInterface
{
use ContainerAwareTrait;

protected static $defaultName = 'payum:status';

/**
Expand Down Expand Up @@ -57,6 +61,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
*/
protected function getPayum()
{
return $this->getContainer()->get('payum');
return $this->container->get('payum');
}
}
8 changes: 8 additions & 0 deletions Form/Extension/GatewayFactoriesChoiceTypeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@ public function getExtendedType()
{
return GatewayFactoriesChoiceType::class;
}

/**
* {@inheritdoc}
*/
public static function getExtendedTypes()
{
return [GatewayFactoriesChoiceType::class];
}
}
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);
}
}
}
Loading

0 comments on commit 9669e1c

Please sign in to comment.