FakeQueryBuilder example

/** * @dataProvider invoicesDataProvider */
    public function testInvoiceLoader(string $orderVersionId, string $versionId, \Closure $expectsClosure): void
    {
        $orderId = Uuid::randomHex();
        $deepLinkCode = 'uojRco91RO5hZ1l6VihVDjKZpWydHVqb';
        $referenceDocumentId = Uuid::randomHex();

        $this->connection->expects(static::once())->method('createQueryBuilder')->willReturn(
            new FakeQueryBuilder($this->connection, [[
                'id' => Uuid::randomHex(),
                'orderId' => $orderId,
                'orderVersionId' => $orderVersionId,
                'versionId' => $versionId,
                'deepLinkCode' => $deepLinkCode,
                'config' => '{}',
            ]]),
        );

        $referenceInvoiceLoader = new ReferenceInvoiceLoader($this->connection);
        $invoice = $referenceInvoiceLoader->load($orderId$referenceDocumentId$deepLinkCode);

        
public function executeQuery(string $sql, array $params = []$types = [], ?QueryCacheProfile $qcp = null): Result
    {
        return new Result(
            new ArrayResult($this->dbRows),
            $this
        );
    }

    public function createQueryBuilder(): QueryBuilder|FakeQueryBuilder
    {
        return new FakeQueryBuilder($this$this->dbRows);
    }
}
static::assertEquals('last', $data['last_name']);
                    static::assertEquals('test@test.com', $data['email']);
                    static::assertEquals($localeId$data['locale_id']);
                    static::assertFalse($data['admin']);
                    static::assertTrue($data['active']);

                    return password_verify('shopware', (string) $data['password']);
                })
            );
        $connection->expects(static::once())->method('fetchOne')->willReturn(json_encode(['_value' => 8]));
        $connection->expects(static::exactly(2))->method('createQueryBuilder')->willReturnOnConsecutiveCalls(
            new FakeQueryBuilder($connection[]),
            new FakeQueryBuilder($connection[[$localeId]])
        );

        $user = [
            'firstName' => 'first',
            'lastName' => 'last',
            'email' => 'test@test.com',
            'admin' => false,
        ];

        $provisioner = new UserProvisioner($connection);
        
static::assertEquals($localeId$data['locale_id']);
                    static::assertTrue($data['admin']);
                    static::assertTrue($data['active']);

                    return password_verify('shopware', (string) $data['password']);
                })
            );

        $connection->expects(static::once())->method('fetchOne')->willReturn(json_encode(['_value' => 8]));

        $connection->method('createQueryBuilder')->willReturnOnConsecutiveCalls(
            new FakeQueryBuilder($connection[]),
            new FakeQueryBuilder($connection[[$localeId]])
        );

        $user = [
            'username' => 'admin',
            'password' => 'shopware',
            'firstName' => 'first',
            'lastName' => 'last',
            'email' => 'test@test.com',
        ];

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