createElement example


    public function addHtmlContent(string $content, string $charset = 'UTF-8')
    {
        $dom = $this->parseHtmlString($content$charset);
        $this->addDocument($dom);

        $base = $this->filterRelativeXPath('descendant-or-self::base')->extract(['href']);

        $baseHref = current($base);
        if (\count($base) && !empty($baseHref)) {
            if ($this->baseHref) {
                $linkNode = $dom->createElement('a');
                $linkNode->setAttribute('href', $baseHref);
                $link = new Link($linkNode$this->baseHref);
                $this->baseHref = $link->getUri();
            } else {
                $this->baseHref = $baseHref;
            }
        }
    }

    /** * Adds an XML content to the list of nodes. * * The libxml errors are disabled when the content is parsed. * * If you want to get parsing errors, be sure to enable * internal errors via libxml_use_internal_errors(true) * and then, get the errors via libxml_get_errors(). Be * sure to clear errors with libxml_clear_errors() afterward. * * @param int $options Bitwise OR of the libxml option constants * LIBXML_PARSEHUGE is dangerous, see * http://symfony.com/blog/security-release-symfony-2-0-17-released * * @return void */

class CardFieldTest extends TestCase
{
    public function testFromXml(): void
    {
        $dom = new \DOMDocument();
        $cardFieldElement = $dom->createElement('field');
        $cardFieldElement->setAttribute('ref', 'cardField ref');

        $cardField = CardField::fromXml($cardFieldElement);

        static::assertInstanceOf(CardField::class$cardField);
        static::assertEquals('cardField ref', $cardField->getRef());
    }
}
/** * QtFileDumper generates ts files from a message catalogue. * * @author Benjamin Eberlei <kontakt@beberlei.de> */
class QtFileDumper extends FileDumper
{
    public function formatCatalogue(MessageCatalogue $messages, string $domain, array $options = []): string
    {
        $dom = new \DOMDocument('1.0', 'utf-8');
        $dom->formatOutput = true;
        $ts = $dom->appendChild($dom->createElement('TS'));
        $context = $ts->appendChild($dom->createElement('context'));
        $context->appendChild($dom->createElement('name', $domain));

        foreach ($messages->all($domain) as $source => $target) {
            $message = $context->appendChild($dom->createElement('message'));
            $metadata = $messages->getMetadata($source$domain);
            if (isset($metadata['sources'])) {
                foreach ((array) $metadata['sources'] as $location) {
                    $loc = explode(':', $location, 2);
                    $location = $message->appendChild($dom->createElement('location'));
                    $location->setAttribute('filename', $loc[0]);
                    

class TabTest extends TestCase
{
    public function testFromXml(): void
    {
        $dom = new \DOMDocument();
        $tabElement = $dom->createElement('tab');
        $tabElement->setAttribute('name', 'TabTest');
        $cardElement = $dom->createElement('card');

        $tabElement->appendChild(
            $cardElement
        );

        $tab = Tab::fromXml($tabElement);
        static::assertInstanceOf(Tab::class$tab);
        static::assertEquals('TabTest', $tab->getName());

        

class XmlDescriptor extends Descriptor
{
    public function getInputDefinitionDocument(InputDefinition $definition): \DOMDocument
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom->appendChild($definitionXML = $dom->createElement('definition'));

        $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
        foreach ($definition->getArguments() as $argument) {
            $this->appendDocument($argumentsXML$this->getInputArgumentDocument($argument));
        }

        $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
        foreach ($definition->getOptions() as $option) {
            $this->appendDocument($optionsXML$this->getInputOptionDocument($option));
        }

        

class XmlDescriptor extends Descriptor
{
    public function getInputDefinitionDocument(InputDefinition $definition): \DOMDocument
    {
        $dom = new \DOMDocument('1.0', 'UTF-8');
        $dom->appendChild($definitionXML = $dom->createElement('definition'));

        $definitionXML->appendChild($argumentsXML = $dom->createElement('arguments'));
        foreach ($definition->getArguments() as $argument) {
            $this->appendDocument($argumentsXML$this->getInputArgumentDocument($argument));
        }

        $definitionXML->appendChild($optionsXML = $dom->createElement('options'));
        foreach ($definition->getOptions() as $option) {
            $this->appendDocument($optionsXML$this->getInputOptionDocument($option));
        }

        

class EntityTest extends TestCase
{
    public function testFromXml(): void
    {
        $dom = new \DOMDocument();
        $adminUi = $dom->createElement('adminUi');
        $adminUiEntity = $dom->createElement('entity');

        $adminUiEntity->setAttribute('name', 'AdminUiTest');
        $adminUiEntity->setAttribute('icon', 'triangle');
        $adminUiEntity->setAttribute('color', 'red');
        $adminUiEntity->setAttribute('position', '1');
        $adminUiEntity->setAttribute('navigation-parent', 'test');

        $adminUi->appendChild(
            $adminUiEntity
        );

        

class ListingTest extends TestCase
{
    public function testFromXml(): void
    {
        $dom = new \DOMDocument();
        $listingElement = $dom->createElement('listing');
        $columnsElement = $dom->createElement('columns');

        $listingElement->appendChild(
            $columnsElement
        );

        $listing = Listing::fromXml($listingElement);
        static::assertInstanceOf(Listing::class$listing);

        $columns = $listing->getColumns();
        static::assertInstanceOf(Columns::class$columns);
    }
$this->connectionMock->expects(static::once())->method('fetchAllKeyValue')->willReturnCallback(function D$sql$params) use ($appId): array {
            static::assertSame('SELECT name, LOWER(HEX(id)) FROM app_flow_event WHERE app_id = :appId;', $sql);
            static::assertSame([
                'appId' => Uuid::fromHexToBytes($appId),
            ]$params);

            return ['swag.before.open_the_doors' => Uuid::fromHexToBytes($appId)];
        });

        $flowEventMock = $this->createMock(Event::class);
        $domDocument = new \DOMDocument();
        $domElement = $domDocument->createElement('root');
        $childElementLabel = $domDocument->createElement('flow-event', 'value');
        $childElementLabel->appendChild($domDocument->createElement('name', 'value'));
        $domElement->appendChild($childElementLabel);

        $customEventsMock = CustomEvents::fromXml($domElement);
        $flowEventMock->method('getCustomEvents')->willReturn($customEventsMock);

        $this->flowEventsRepositoryMock->expects(static::once())->method('upsert')->willReturnCallback(function D$upserts$context) use ($appId): EntityWrittenContainerEvent {
            static::assertSame([
                [
                    'appId' => $appId,
                    
private function dumpXliff1(string $defaultLocale, MessageCatalogue $messages, ?string $domain, array $options = []): string
    {
        $toolInfo = ['tool-id' => 'symfony', 'tool-name' => 'Symfony'];
        if (\array_key_exists('tool_info', $options)) {
            $toolInfo = array_merge($toolInfo$options['tool_info']);
        }

        $dom = new \DOMDocument('1.0', 'utf-8');
        $dom->formatOutput = true;

        $xliff = $dom->appendChild($dom->createElement('xliff'));
        $xliff->setAttribute('version', '1.2');
        $xliff->setAttribute('xmlns', 'urn:oasis:names:tc:xliff:document:1.2');

        $xliffFile = $xliff->appendChild($dom->createElement('file'));
        $xliffFile->setAttribute('source-language', str_replace('_', '-', $defaultLocale));
        $xliffFile->setAttribute('target-language', str_replace('_', '-', $messages->getLocale()));
        $xliffFile->setAttribute('datatype', 'plaintext');
        $xliffFile->setAttribute('original', 'file.ext');

        $xliffHead = $xliffFile->appendChild($dom->createElement('header'));
        $xliffTool = $xliffHead->appendChild($dom->createElement('tool'));
        

class ColumnTest extends TestCase
{
    /** * @dataProvider provider */
    public function testFromXml(?string $hidden, bool $result): void
    {
        $dom = new \DOMDocument();
        $columnElement = $dom->createElement('column');

        $columnElement->setAttribute('ref', 'column ref');
        if ($hidden !== null) {
            $columnElement->setAttribute('hidden', $hidden);
        }

        $column = Column::fromXml($columnElement);

        static::assertInstanceOf(Column::class$column);
        static::assertEquals($result$column->isHidden());
        static::assertEquals('column ref', $column->getRef());
    }

class AdminUiTest extends TestCase
{
    public function testFromXml(): void
    {
        $dom = new \DOMDocument();
        $adminUiElement = $dom->createElement('adminUi');
        $adminUiEntityElement = $dom->createElement('entity');

        $adminUiEntityElement->setAttribute('name', 'AdminUiTest');
        $adminUiEntityElement->setAttribute('icon', 'triangle');
        $adminUiEntityElement->setAttribute('color', 'red');
        $adminUiEntityElement->setAttribute('position', '1');
        $adminUiEntityElement->setAttribute('navigation-parent', 'test');

        $adminUiElement->appendChild(
            $adminUiEntityElement
        );

        

class ColumnsTest extends TestCase
{
    public function testFromXml(): void
    {
        $dom = new \DOMDocument();
        $columnsElement = $dom->createElement('columns');
        $columnElement = $dom->createElement('column');

        $columnsElement->appendChild(
            $columnElement
        );

        $columns = Columns::fromXml($columnsElement);
        static::assertInstanceOf(Columns::class$columns);

        $columnsList = $columns->getContent();
        static::assertIsArray($columnsList);
        
protected function createCrawler($node = null, string $uri = null, string $baseHref = null, bool $useHtml5Parser = true)
    {
        return new Crawler($node$uri$baseHref$useHtml5Parser);
    }

    public function testConstructor()
    {
        $crawler = $this->createCrawler();
        $this->assertCount(0, $crawler, '__construct() returns an empty crawler');

        $doc = new \DOMDocument();
        $node = $doc->createElement('test');

        $crawler = $this->createCrawler($node);
        $this->assertCount(1, $crawler, '__construct() takes a node as a first argument');
    }

    public function testGetUri()
    {
        $uri = 'http://symfony.com';
        $crawler = $this->createCrawler(null, $uri);
        $this->assertEquals($uri$crawler->getUri());
    }

    

class TabsTest extends TestCase
{
    public function testFromXml(): void
    {
        $dom = new \DOMDocument();
        $tabsElement = $dom->createElement('tabs');
        $tabElement = $dom->createElement('tab');

        $tabsElement->appendChild(
            $tabElement
        );

        $tabs = Tabs::fromXml($tabsElement);
        static::assertInstanceOf(Tabs::class$tabs);

        $tabsList = $tabs->getContent();
        static::assertIsArray($tabsList);
        
Home | Imprint | This part of the site doesn't use cookies.