Skip to content

Commit

Permalink
Fix phpstan issues
Browse files Browse the repository at this point in the history
  • Loading branch information
AydinHassan committed Jan 19, 2024
1 parent 7416afa commit 0296b79
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 33 deletions.
6 changes: 2 additions & 4 deletions tests/Checkout/Cart/ExcludedProductValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,8 @@ public function testIsExcludedProduct(?string $settingKey, ?string $settingIdNam

/**
* this test is related to the ExpressCheckoutSubscriber
*
* @dataProvider dataProviderConstellations
*/
#[DataProvider('dataProviderConstellations')]
public function testExcludedProductTaggedInSearchResults(?string $settingKey, ?string $settingIdName, ?string $expectedIdName): void
{
if ($settingKey && $settingIdName) {
Expand All @@ -179,9 +178,8 @@ public function testExcludedProductTaggedInSearchResults(?string $settingKey, ?s

/**
* this test is related to the ExpressCheckoutSubscriber
*
* @dataProvider dataProviderConstellations
*/
#[DataProvider('dataProviderConstellations')]
public function testExcludedProductTaggedInSearchResultsWithListingDisabled(?string $settingKey, ?string $settingIdName): void
{
if ($settingKey && $settingIdName) {
Expand Down
4 changes: 2 additions & 2 deletions tests/Migration/Migration1692001928VaultTokenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
namespace Swag\PayPal\Test\Migration;

use Doctrine\DBAL\Connection;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Test\TestCaseBase\DatabaseTransactionBehaviour;
use Shopware\Core\Framework\Test\TestCaseBase\KernelTestBehaviour;
use Swag\PayPal\Migration\Migration1692001928VaultToken;

/**
* @covers \Swag\PayPal\Migration\Migration1692001928VaultToken
*
* @internal
*/
#[Package('checkout')]
#[CoversClass(\Swag\PayPal\Migration\Migration1692001928VaultToken::class)]
class Migration1692001928VaultTokenTest extends TestCase
{
use DatabaseTransactionBehaviour;
Expand Down
12 changes: 4 additions & 8 deletions tests/OrdersApi/Builder/APMOrderBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ class APMOrderBuilderTest extends TestCase
/**
* @param class-string<AbstractAPMOrderBuilder> $orderBuilderClass
* @param class-string<AbstractAPMPaymentSource> $structClass
*
* @dataProvider dataProviderAPM
*/
#[DataProvider('dataProviderAPM')]
public function testGetOrder(string $orderBuilderClass, array $requestData, string $structClass, array $expectedStructData): void
{
$orderBuilder = $this->createOrderBuilder($orderBuilderClass);
Expand Down Expand Up @@ -116,9 +115,8 @@ public function testGetOrder(string $orderBuilderClass, array $requestData, stri

/**
* @param class-string<AbstractAPMOrderBuilder> $orderBuilderClass
*
* @dataProvider dataProviderAPM
*/
#[DataProvider('dataProviderAPM')]
public function testGetOrderNoBillingAddress(string $orderBuilderClass, array $requestData): void
{
$orderBuilder = $this->createOrderBuilder($orderBuilderClass);
Expand All @@ -138,9 +136,8 @@ public function testGetOrderNoBillingAddress(string $orderBuilderClass, array $r

/**
* @param class-string<AbstractAPMOrderBuilder> $orderBuilderClass
*
* @dataProvider dataProviderAPM
*/
#[DataProvider('dataProviderAPM')]
public function testGetOrderNoShippingAddress(string $orderBuilderClass, array $requestData): void
{
$orderBuilder = $this->createOrderBuilder($orderBuilderClass);
Expand All @@ -160,9 +157,8 @@ public function testGetOrderNoShippingAddress(string $orderBuilderClass, array $

/**
* @param class-string<AbstractAPMOrderBuilder> $orderBuilderClass
*
* @dataProvider dataProviderAPM
*/
#[DataProvider('dataProviderAPM')]
public function testGetOrderPrefix(string $orderBuilderClass, array $requestData): void
{
$paymentTransaction = $this->createPaymentTransactionStruct(ConstantsForTesting::VALID_ORDER_ID);
Expand Down
2 changes: 1 addition & 1 deletion tests/Pos/Mock/Repositories/RepoTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function updateCollection(array $data, Context $context): EntityWritte
$entity->setUniqueIdentifier($this->getUniqueIdentifier($entity));

if ($this->entityCollection->has($entity->getUniqueIdentifier())) {
$entity = $this->entityCollection->get($entity->getUniqueIdentifier()) ?? $entity;
$entity = $this->entityCollection->get($entity->getUniqueIdentifier());
$entity->assign($entry);
}

Expand Down
6 changes: 2 additions & 4 deletions tests/Pos/Run/RunTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,9 @@ public static function dataProviderRunTaskName(): array
}

/**
* @dataProvider dataProviderRunTaskName
*
* @param class-string<AbstractTask> $taskName
*/
#[DataProvider('dataProviderRunTaskName')]
public function testNames(string $taskName, string $expectedName): void
{
/** @var AbstractTask&MockObject $task */
Expand Down Expand Up @@ -120,10 +119,9 @@ public static function dataProviderExecution(): array
}

/**
* @dataProvider dataProviderExecution
*
* @param class-string<AbstractTask> $taskName
*/
#[DataProvider('dataProviderExecution')]
public function testExecution(string $taskName, array $serviceCalls): void
{
$context = Context::createDefaultContext();
Expand Down
9 changes: 3 additions & 6 deletions tests/ShopwarePluginClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* file that was distributed with this source code.
*/

use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
use Shopware\Core\Framework\Log\Package;
use Shopware\Core\Framework\Plugin;
Expand All @@ -25,9 +26,7 @@ public function testHasComposerJson(): void
static::assertFileExists(__DIR__ . '/../composer.json');
}

/**
* @depends testHasComposerJson
*/
#[Depends('testHasComposerJson')]
public function testClassExists(): void
{
$composer = json_decode((string) file_get_contents(__DIR__ . '/../composer.json'), true);
Expand All @@ -43,9 +42,7 @@ public function testClassExists(): void
static::assertContains(Plugin::class, $parents, '`' . $class . '` should extend ' . Plugin::class);
}

/**
* @depends testClassExists
*/
#[Depends('testClassExists')]
public function testPluginIsLoaded(): void
{
$composer = json_decode((string) file_get_contents(__DIR__ . '/../composer.json'), true);
Expand Down
8 changes: 6 additions & 2 deletions tests/TestBootstrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public function getClassLoader(): ClassLoader
if (\is_string($paths)) {
$paths = [$paths];
}
$mappedPaths = $this->mapPsrPaths($paths, realpath(dirname($pathToComposerJson)));
$mappedPaths = $this->mapPsrPaths($paths, dirname($pathToComposerJson));

$this->classLoader->addPsr4($namespace, $mappedPaths);
if ($this->classLoader->isClassMapAuthoritative()) {
Expand All @@ -145,7 +145,7 @@ public function getClassLoader(): ClassLoader
if (\is_string($paths)) {
$paths = [$paths];
}
$mappedPaths = $this->mapPsrPaths($paths, realpath(dirname($pathToComposerJson)));
$mappedPaths = $this->mapPsrPaths($paths, dirname($pathToComposerJson));

$this->classLoader->add($namespace, $mappedPaths);
if ($this->classLoader->isClassMapAuthoritative()) {
Expand All @@ -157,6 +157,10 @@ public function getClassLoader(): ClassLoader
return $classLoader;
}

/**
* @param list<string> $psr
* @return list<string>
*/
private function mapPsrPaths(array $psr, string $pluginRootPath): array
{
$mappedPaths = [];
Expand Down
9 changes: 3 additions & 6 deletions tests/Util/Availability/AvailabilityServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ protected function setUp(): void
}

/**
* @dataProvider dataProviderPaymentMethod
*
* @param class-string<AbstractMethodData> $methodDataClass
*/
#[DataProvider('dataProviderPaymentMethod')]
public function testIsPaymentMethodAvailable(string $methodDataClass, bool $shouldBeAvailable): void
{
$salesChannelContext = $this->createSalesChannelContext();
Expand All @@ -82,10 +81,9 @@ public function testIsPaymentMethodAvailable(string $methodDataClass, bool $shou
}

/**
* @dataProvider dataProviderPaymentMethod
*
* @param class-string<AbstractMethodData> $methodDataClass
*/
#[DataProvider('dataProviderPaymentMethod')]
public function testFilterPaymentMethods(string $methodDataClass, bool $shouldBeAvailable): void
{
$salesChannelContext = $this->createSalesChannelContext();
Expand All @@ -99,10 +97,9 @@ public function testFilterPaymentMethods(string $methodDataClass, bool $shouldBe
}

/**
* @dataProvider dataProviderPaymentMethod
*
* @param class-string<AbstractMethodData> $methodDataClass
*/
#[DataProvider('dataProviderPaymentMethod')]
public function testFilterPaymentMethodByOrder(string $methodDataClass, bool $shouldBeAvailable): void
{
$salesChannelContext = $this->createSalesChannelContext();
Expand Down

0 comments on commit 0296b79

Please sign in to comment.