Skip to content

Commit

Permalink
Merge pull request #183 in PLUG_OPEN/swagpaymentpaypalunified from pt…
Browse files Browse the repository at this point in the history
…-10430/5.6/5.6-compatibility to master

* commit '24129846c0f1bdc6f1d214ffc827659d04929974':
  PT-10430 - 5.6 compatibility
  • Loading branch information
htkassner committed Jul 5, 2019
2 parents 97e0a5d + 2412984 commit 6bd4401
Show file tree
Hide file tree
Showing 54 changed files with 267 additions and 120 deletions.
11 changes: 9 additions & 2 deletions Components/Document/InvoiceDocumentHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,21 @@ class InvoiceDocumentHandler
*/
private $snippetManager;

/**
* @var \Shopware_Components_Translation
*/
private $translation;

public function __construct(
PaymentInstructionService $instructionService,
Connection $dbalConnection,
SnippetManager $snippetManager
SnippetManager $snippetManager,
\Shopware_Components_Translation $translation
) {
$this->instructionService = $instructionService;
$this->dbalConnection = $dbalConnection;
$this->snippetManager = $snippetManager;
$this->translation = $translation;
}

/**
Expand Down Expand Up @@ -93,7 +100,7 @@ public function handleDocument($orderNumber, Document $document)
public function getInvoiceContainer($containers, $orderData)
{
$footer = $containers['PayPal_Unified_Instructions_Content'];
$translation = (new \Shopware_Components_Translation())->read(
$translation = $this->translation->read(
$orderData['_order']['language'],
'documents',
$footer['id']
Expand Down
1 change: 1 addition & 0 deletions Resources/services/subscribers.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<argument type="service" id="paypal_unified.payment_instruction_service"/>
<argument type="service" id="dbal_connection"/>
<argument type="service" id="snippets"/>
<argument type="service" id="translation" on-invalid="null"/>
<tag name="shopware.event_subscriber"/>
</service>

Expand Down
13 changes: 9 additions & 4 deletions Setup/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class Installer
*/
private $bootstrapPath;

/**
* @var Shopware_Components_Translation
*/
private $translation;

/**
* Installer constructor.
*
Expand All @@ -47,11 +52,13 @@ public function __construct(
ModelManager $modelManager,
Connection $connection,
CrudService $attributeCrudService,
Shopware_Components_Translation $translation,
$bootstrapPath
) {
$this->modelManager = $modelManager;
$this->connection = $connection;
$this->attributeCrudService = $attributeCrudService;
$this->translation = $translation;
$this->bootstrapPath = $bootstrapPath;
}

Expand Down Expand Up @@ -230,9 +237,7 @@ private function writeTranslation()
/** @var array $translationKeys */
$translationKeys = $this->getTranslationKeys();

$translation = new Shopware_Components_Translation();

$translation->write(
$this->translation->write(
2,
'config_payment',
$translationKeys['SwagPaymentPayPalUnified'],
Expand All @@ -246,7 +251,7 @@ private function writeTranslation()
true
);

$translation->write(
$this->translation->write(
2,
'config_payment',
$translationKeys['SwagPaymentPayPalUnifiedInstallments'],
Expand Down
17 changes: 15 additions & 2 deletions Subscriber/Documents/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Doctrine\DBAL\Connection;
use Enlight\Event\SubscriberInterface;
use Shopware_Components_Snippet_Manager as SnippetManager;
use Shopware_Components_Translation;
use SwagPaymentPayPalUnified\Components\Document\InvoiceDocumentHandler;
use SwagPaymentPayPalUnified\Components\PaymentMethodProvider;
use SwagPaymentPayPalUnified\Components\Services\Plus\PaymentInstructionService;
Expand All @@ -33,14 +34,25 @@ class Invoice implements SubscriberInterface
*/
private $snippetManager;

/**
* @var Shopware_Components_Translation
*/
private $translation;

public function __construct(
PaymentInstructionService $paymentInstructionService,
Connection $dbalConnection,
SnippetManager $snippetManager
SnippetManager $snippetManager,
Shopware_Components_Translation $translation = null
) {
$this->paymentInstructionsService = $paymentInstructionService;
$this->dbalConnection = $dbalConnection;
$this->snippetManager = $snippetManager;
$this->translation = $translation;

if ($this->translation === null) {
$this->translation = new Shopware_Components_Translation();
}
}

/**
Expand Down Expand Up @@ -82,7 +94,8 @@ public function onBeforeRenderDocument(\Enlight_Hook_HookArgs $args)
$documentHandler = new InvoiceDocumentHandler(
$this->paymentInstructionsService,
$this->dbalConnection,
$this->snippetManager
$this->snippetManager,
$this->translation
);
$documentHandler->handleDocument($orderNumber, $document);
}
Expand Down
3 changes: 3 additions & 0 deletions SwagPaymentPayPalUnified.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ public function build(ContainerBuilder $container)
*/
public function install(InstallContext $context)
{
$translation = $this->container->has('translation') ? $this->container->get('translation') : new \Shopware_Components_Translation();

$installer = new Installer(
$this->container->get('models'),
$this->container->get('dbal_connection'),
$this->container->get('shopware_attribute.crud_service'),
$translation,
$this->getPath()
);

Expand Down
11 changes: 7 additions & 4 deletions Tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ public static function start()
/** @var $repository \Shopware\Models\Shop\Repository */
$repository = $container->get('models')->getRepository(Shop::class);

$shop = $repository->getActiveDefault();
$shop->registerResources();

$_SERVER['HTTP_HOST'] = $shop->getHost();
if ($container->has('shopware.components.shop_registration_service')) {
$container->get('shopware.components.shop_registration_service')->registerResources(
$repository->getActiveDefault()
);
} else {
$repository->getActiveDefault()->registerResources();
}

if (!self::isPluginInstalledAndActivated()) {
die('Error: The plugin is not installed or activated, tests aborted!');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

namespace SwagPaymentPayPalUnified\Tests\Functional\Bundle\AccountBundle\Service\Validator;

use PHPUnit\Framework\TestCase;
use Shopware\Bundle\AccountBundle\Service\Validator\AddressValidatorInterface as AddressValInterface;
use Shopware\Components\Api\Exception\ValidationException;
use Shopware\Models\Customer\Address;
use SwagPaymentPayPalUnified\Bundle\AccountBundle\Service\Validator\AddressValidatorDecorator as AddressDecorator;
use Symfony\Component\Validator\ConstraintViolation;
use Symfony\Component\Validator\ConstraintViolationList;

class AddressValidatorDecoratorTest extends \PHPUnit_Framework_TestCase
class AddressValidatorDecoratorTest extends TestCase
{
public function test_construct()
{
Expand Down
3 changes: 2 additions & 1 deletion Tests/Functional/Components/DependencyProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

namespace SwagPaymentPayPalUnified\Tests\Functional\Components;

use PHPUnit\Framework\TestCase;
use Shopware\Components\DependencyInjection\Container;
use Shopware\Models\Shop\DetachedShop;
use SwagPaymentPayPalUnified\Components\DependencyProvider;

class DependencyProviderTest extends \PHPUnit_Framework_TestCase
class DependencyProviderTest extends TestCase
{
public function test_service_available()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
namespace SwagPaymentPayPalUnified\Tests\Functional\Components\Document;

use Doctrine\DBAL\Connection;
use PHPUnit\Framework\TestCase;
use SwagPaymentPayPalUnified\Components\Document\InstallmentsDocumentHandler;
use SwagPaymentPayPalUnified\Tests\Functional\DatabaseTestCaseTrait;

class InstallmentsDocumentHandlerTest extends \PHPUnit_Framework_TestCase
class InstallmentsDocumentHandlerTest extends TestCase
{
use DatabaseTestCaseTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
namespace SwagPaymentPayPalUnified\Tests\Functional\Components\ExpressCheckout;

use Doctrine\DBAL\Connection;
use PHPUnit\Framework\TestCase;
use SwagPaymentPayPalUnified\Components\ExpressCheckout\CustomerService;
use SwagPaymentPayPalUnified\PayPalBundle\Structs\Common\Address;
use SwagPaymentPayPalUnified\PayPalBundle\Structs\Payment;
use SwagPaymentPayPalUnified\PayPalBundle\Structs\Payment\Payer;
use SwagPaymentPayPalUnified\PayPalBundle\Structs\Payment\Payer\PayerInfo;
use SwagPaymentPayPalUnified\Tests\Functional\DatabaseTestCaseTrait;

class CustomerServiceTest extends \PHPUnit_Framework_TestCase
class CustomerServiceTest extends TestCase
{
use DatabaseTestCaseTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

namespace SwagPaymentPayPalUnified\Tests\Functional\Components\Installments;

use PHPUnit\Framework\TestCase;
use SwagPaymentPayPalUnified\Components\Installments\FinancingOptionsHandler;
use SwagPaymentPayPalUnified\PayPalBundle\Structs\Installments\FinancingResponse;

class FinancingOptionsHandlerTest extends \PHPUnit_Framework_TestCase
class FinancingOptionsHandlerTest extends TestCase
{
public function test_can_be_constructed()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@

namespace SwagPaymentPayPalUnified\Tests\Functional\Components\Services\ExpressCheckout;

use PHPUnit\Framework\TestCase;
use SwagPaymentPayPalUnified\Components\PaymentBuilderParameters;
use SwagPaymentPayPalUnified\Components\Services\ExpressCheckout\ExpressCheckoutPaymentBuilderService;
use SwagPaymentPayPalUnified\Components\Services\Validation\BasketIdWhitelist;
use SwagPaymentPayPalUnified\PayPalBundle\Components\SettingsServiceInterface;
use SwagPaymentPayPalUnified\PayPalBundle\Structs\Payment;
use SwagPaymentPayPalUnified\Tests\Functional\Components\Services\SettingsServicePaymentBuilderServiceMock;

class ExpressCheckoutPaymentBuilderServiceTest extends \PHPUnit_Framework_TestCase
class ExpressCheckoutPaymentBuilderServiceTest extends TestCase
{
public function test_serviceIsAvailable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

namespace SwagPaymentPayPalUnified\Tests\Functional\Components\Services\Installments;

use PHPUnit\Framework\TestCase;
use SwagPaymentPayPalUnified\Components\Services\Installments\CompanyInfoService;

class CompanyInfoServiceTest extends \PHPUnit_Framework_TestCase
class CompanyInfoServiceTest extends TestCase
{
public function test_can_be_constructed()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

namespace SwagPaymentPayPalUnified\Tests\Functional\Components\Services\Installments;

use PHPUnit\Framework\TestCase;
use SwagPaymentPayPalUnified\Components\PaymentBuilderParameters;
use SwagPaymentPayPalUnified\Components\Services\Installments\InstallmentsPaymentBuilderService;
use SwagPaymentPayPalUnified\Components\Services\PaymentBuilderService;
use SwagPaymentPayPalUnified\PayPalBundle\Components\SettingsServiceInterface;
use SwagPaymentPayPalUnified\Tests\Functional\Components\Services\SettingsServicePaymentBuilderServiceMock;

class InstallmentsPaymentBuilderServiceTest extends \PHPUnit_Framework_TestCase
class InstallmentsPaymentBuilderServiceTest extends TestCase
{
public function test_serviceIsAvailable()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
namespace SwagPaymentPayPalUnified\Tests\Functional\Components\Services\Installments;

use Doctrine\DBAL\Connection;
use PHPUnit\Framework\TestCase;
use SwagPaymentPayPalUnified\Components\Services\Installments\OrderCreditInfoService;
use SwagPaymentPayPalUnified\Models\FinancingInformation;
use SwagPaymentPayPalUnified\PayPalBundle\Structs\Payment\Credit;
use SwagPaymentPayPalUnified\Tests\Functional\DatabaseTestCaseTrait;

class OrderCreditInfoServiceTest extends \PHPUnit_Framework_TestCase
class OrderCreditInfoServiceTest extends TestCase
{
use DatabaseTestCaseTrait;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

namespace SwagPaymentPayPalUnified\Tests\Functional\Components\Services\Legacy;

use PHPUnit\Framework\TestCase;
use SwagPaymentPayPalUnified\Components\Services\Legacy\LegacyService;
use SwagPaymentPayPalUnified\Tests\Functional\DatabaseTestCaseTrait;

class LegacyServiceTest extends \PHPUnit_Framework_TestCase
class LegacyServiceTest extends TestCase
{
use DatabaseTestCaseTrait;

Expand Down
3 changes: 2 additions & 1 deletion Tests/Functional/Components/Services/LoggerServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

namespace SwagPaymentPayPalUnified\Tests\Functional\Components\Services;

use PHPUnit\Framework\TestCase;
use SwagPaymentPayPalUnified\PayPalBundle\Components\LoggerServiceInterface;
use SwagPaymentPayPalUnified\Tests\Functional\DatabaseTestCaseTrait;
use SwagPaymentPayPalUnified\Tests\Functional\SettingsHelperTrait;

class LoggerServiceTest extends \PHPUnit_Framework_TestCase
class LoggerServiceTest extends TestCase
{
use DatabaseTestCaseTrait;
use SettingsHelperTrait;
Expand Down
Loading

0 comments on commit 6bd4401

Please sign in to comment.