assertXmlStringEqualsXmlString example

->with($domains$locales)
            ->willReturn($providerReadTranslatorBag);

        $provider->expects($this->once())
            ->method('__toString')
            ->willReturn('null://default');

        $tester = $this->createCommandTester($provider$locales$domains);
        $tester->execute(['--locales' => ['en', 'fr'], '--domains' => ['messages', 'messages+intl-icu']]);

        $this->assertStringContainsString('[OK] New translations from "null" has been written locally (for "en, fr" locale(s), and "messages, messages+intl-icu"', trim($tester->getDisplay()));
        $this->assertXmlStringEqualsXmlString(<<<XLIFF <?xml version="1.0"?> <xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2"> <file source-language="en" target-language="en" datatype="plaintext" original="file.ext"> <header> <tool tool-id="symfony" tool-name="Symfony"/> </header> <body> <trans-unit id="994ixRL" resname="new.foo"> <source>new.foo</source> <target>newFoo</target> </trans-unit> <trans-unit id="7bRlYkK" resname="note"> <source>note</source> <target>NOTE</target> </trans-unit> </body> </file> </xliff>
/** * @dataProvider mapRequestPayloadProvider */
    public function testMapRequestPayload(string $format, array $parameters, ?string $content, string $expectedResponse, int $expectedStatusCode)
    {
        $client = self::createClient(['test_case' => 'ApiAttributesTest']);

        [$acceptHeader$assertion] = [
            'html' => ['text/html', self::assertStringContainsString(...)],
            'json' => ['application/json', self::assertJsonStringEqualsJsonString(...)],
            'xml' => ['text/xml', self::assertXmlStringEqualsXmlString(...)],
            'dummy' => ['application/dummy', self::assertStringContainsString(...)],
        ][$format];

        $client->request(
            'POST',
            '/map-request-body.'.$format,
            $parameters,
            [],
            ['HTTP_ACCEPT' => $acceptHeader, 'CONTENT_TYPE' => $acceptHeader],
            $content
        );

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