Project: shopware6
Filename: repositories/php/shopware6/src/Storefront/Test/Framework/Routing/StorefrontSubscriberTest.php
public function testItAddsShopIdParam(): void
{ $this->
loadAppsFromDir(__DIR__ . '/../../Theme/fixtures/Apps/noThemeNoCss'
);
$eventDispatcher =
$this->
getContainer()->
get('event_dispatcher'
);
$event =
new StorefrontRenderEvent( 'testView',
[],
new Request(),
$this->salesChannelContext
);
$eventDispatcher->
dispatch($event);
static::
assertArrayHasKey('appShopId',
$event->
getParameters());
} public function testItDoesNotAddShopIdParamWhenAppIsInactive(): void
{ $this->
loadAppsFromDir(__DIR__ . '/../../Theme/fixtures/Apps/noThemeNoCss', false
);
Project: shopware6
Filename: repositories/php/shopware6/src/Core/Framework/Test/Routing/ApiRequestContextResolverTest.php
/**
* @dataProvider userRoleProvider
*
* @param array<string, bool> $expected
* @param array<string, list<string>> $roles
*/
public function testResolveAdminSourceByOAuthUserId(array
$expected, array
$roles, bool
$isAdmin = false
): void
{ $user =
$this->
createUser($roles,
$isAdmin);
$request =
new Request();
$request->attributes->
set(PlatformRequest::ATTRIBUTE_OAUTH_USER_ID,
$user->
getUserId());
$request->attributes->
set('_routeScope',
['api'
]);
$this->resolver->
resolve($request);
static::
assertTrue( $request->attributes->
has(PlatformRequest::ATTRIBUTE_CONTEXT_OBJECT
) );
/** @var Context $context */
$context =
$request->attributes->
get(PlatformRequest::ATTRIBUTE_CONTEXT_OBJECT
);
Project: shopware6
Filename: repositories/php/shopware6/tests/integration/php/Core/Framework/App/Lifecycle/Registration/StoreHandshakeTest.php
public function testThrowsIfSbpRespondsWithUnauthorized(): void
{ $storeClient =
$this->
createMock(StoreClient::
class);
$json = \
json_encode(['code' => 'ShopwarePlatformException-1'
]);
static::
assertNotFalse($json);
$storeClient->
method('signPayloadWithAppSecret'
) ->
willThrowException(new ClientException( '',
new Request('POST', 'app_generate_signature'
),
new Response(401,
[],
$json) ));
$handshake =
new StoreHandshake( 'http://shop.url',
'http://app.url',
'TestApp',
'my-shop-id',
$storeClient,
Kernel::SHOPWARE_FALLBACK_VERSION
);
Project: shopware6
Filename: repositories/php/shopware6/src/WebInstaller/tests/Controller/FinishControllerTest.php
Project: shopware6
Filename: repositories/php/shopware6/src/Storefront/Test/Framework/Captcha/GoogleReCaptchaV3Test.php
return [
'with get method and inactive captcha' => ['GET', false, false],
'with get method and active captcha' => ['GET', true, false],
'with post method and inactive captcha' => ['POST', false, false],
'with post method and active captcha' => ['POST', true, true],
];
}
private static function getRequest(array $data = []): Request
{
return new Request([], $data, [], [], [], [], []);
}
}
Project: shopware6
Filename: repositories/php/shopware6/tests/unit/php/Core/Framework/Api/Controller/CustomSnippetFormatControllerTest.php
'address/title',
'address/zipcode',
'symbol/comma',
'symbol/dash',
'symbol/tilde',
'custom-snippet/custom-snippet',
],
$content['data'
]);
} public function testRender(): void
{ $request =
new Request();
$request->request->
set('data',
[ 'customer' =>
[ 'first_name' => 'Vin',
'last_name' => 'Le',
],
]);
$request->request->
set('format',
[ [ 'address/first_name',
'address/last_name',
],
]);
Project: shopware6
Filename: repositories/php/shopware6/src/Core/Content/Test/Category/SalesChannel/CachedNavigationRouteTest.php
function DIdsCollection
$ids, SalesChannelContext
$context, ContainerInterface
$container): void
{ $container->
get('category.repository'
)->
create([ ['id' =>
$ids->
get('cat-1.2.4'
), 'name' => 'cat 1.2.4', 'active' => true
],
], Context::
createDefaultContext());
},
3,
];
} private static function request(int
$depth): Request
{ $request =
new Request();
$request->query->
set('depth',
$depth);
$request->query->
set('buildTree', false
);
return $request;
} private function initData(IdsCollection
$ids): void
{ $context =
$this->
getContainer() ->
get(SalesChannelContextFactory::
class) ->
create(Uuid::
randomHex(), TestDefaults::SALES_CHANNEL
);
Project: shopware6
Filename: repositories/php/shopware6/src/WebInstaller/tests/Services/RecoveryManagerTest.php
Project: shopware6
Filename: repositories/php/shopware6/src/Storefront/Test/Page/Account/PaymentMethodPageTest.php
/**
* @internal
*/
class PaymentMethodPageTest extends TestCase
{ use IntegrationTestBehaviour;
use StorefrontPageTestBehaviour;
public function testItlLoadsTheRequestedCustomersData(): void
{ $request =
new Request();
$context =
$this->
createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
/** @var AccountPaymentMethodPageLoadedEvent $event */
$event = null;
$this->
catchEvent(AccountPaymentMethodPageLoadedEvent::
class,
$event);
$page =
$this->
getPageLoader()->
load($request,
$context);
static::
assertInstanceOf(AccountPaymentMethodPage::
class,
$page);
static::
assertSame(StorefrontPageTestConstants::PAYMENT_METHOD_COUNT,
$page->
getPaymentMethods()->
count());
self::
assertPageEvent(AccountPaymentMethodPageLoadedEvent::
class,
$event,
$context,
$request,
$page);
}Project: shopware6
Filename: repositories/php/shopware6/src/Storefront/Test/Page/Product/QuickView/MinimalQuickViewPageTest.php
/**
* @internal
*/
class MinimalQuickViewPageTest extends TestCase
{ use IntegrationTestBehaviour;
use StorefrontPageTestBehaviour;
public function testItRequiresProductParam(): void
{ $request =
new Request();
$context =
$this->
createSalesChannelContext();
$this->
expectParamMissingException('productId'
);
$this->
getPageLoader()->
load($request,
$context);
} public function testItRequiresAValidProductParam(): void
{ $request =
new Request([],
[],
['productId' => '99999911ffff4fffafffffff19830531'
]);
$context =
$this->
createSalesChannelContext();
Project: shopware6
Filename: repositories/php/shopware6/tests/unit/php/Core/Content/Product/SalesChannel/Suggest/ProductSuggestRouteTest.php
Project: shopware6
Filename: repositories/php/shopware6/src/Core/Content/Test/Product/SalesChannel/ProductListingFilterOutOfStockTest.php