getConnectionMock example

/** * @internal * * @covers \Shopware\Administration\Snippet\SnippetFinder */
class SnippetFinderTest extends TestCase
{
    public function testFindSnippetsFromAppNoSnippetsAdded(): void
    {
        $snippetFinder = new SnippetFinder(
            $this->getKernelWithNoPlugins(),
            $this->getConnectionMock('en-GB', [])
        );

        $snippets = $snippetFinder->findSnippets('en-GB');
        static::assertArrayNotHasKey('my-custom-snippet-key', $snippets);
    }

    public function testFindSnippetsFromApp(): void
    {
        $snippetFinder = new SnippetFinder(
            $this->getKernelWithNoPlugins(),
            $this->getConnectionMock('en-GB', $this->getSnippetFixtures())
        );
static::assertEquals($expectedEvents, CmsPageDefaultChangeSubscriber::getSubscribedEvents());
    }

    /** * @param list<string> $event * @param array<mixed> $connectionData * * @dataProvider beforeDeletionEventDataProvider */
    public function testBeforeDeletionEvent(array $event, array $connectionData, ?string $expectedExceptionCode = null): void
    {
        $connection = $this->getConnectionMock($connectionData);
        $cmsPageDefaultChangeSubscriber = new CmsPageDefaultChangeSubscriber($connection);
        $exceptionWasThrown = false;

        try {
            $cmsPageDefaultChangeSubscriber->beforeDeletion($this->getBeforeDeleteEvent($event));
        } catch (CmsException $exception) {
            if ($expectedExceptionCode) {
                static::assertEquals($expectedExceptionCode$exception->getErrorCode());
                $exceptionWasThrown = true;
            }
        } finally {
            
$path = 'order_line_items';

        $commands = [new UpdateCommand(
            $definition,
            ['referenced_id' => 'new_referenced_id'],
            $primaryKey,
            $existence,
            $path
        )];

        $stockSubscriber = new StockUpdater(
            $this->getConnectionMock(),
            $this->dispatcher,
            new StockUpdateFilterProvider([]),
        );

        $writeContextMock = $this->getMockBuilder(WriteContext::class)
            ->disableOriginalConstructor()
            ->getMock();

        $event = new PreWriteValidationEvent($writeContextMock$commands);
        $stockSubscriber->triggerChangeSet($event);

        
Home | Imprint | This part of the site doesn't use cookies.