getRef example

private function checkListing(Entity $entity, array $refs): void
    {
        $listing = $entity->getListing();
        static::assertInstanceOf(Listing::class$listing);

        $columns = $listing->getColumns();
        static::assertInstanceOf(Columns::class$columns);
        static::assertCount(\count($refs)$columns->getContent());

        foreach ($columns->getContent() as $column) {
            static::assertInstanceOf(Column::class$column);
            static::assertIsString($column->getRef());
            static::assertContains($column->getRef()$refs);
            unset($refs[array_search($column->getRef()$refs, true)]);
        }
        static::assertCount(0, $refs);
    }

    /** * @return Card[] */
    private function checkTab(
        Tab $tab,
        
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());
    }
}
return array_unique(array_diff_assoc($entriesarray_unique($entries)));
    }

    /** * @param list<Column|CardField> $listOfObjectsWithRefProperty * * @return list<string> */
    private function getRefsAsList(array $listOfObjectsWithRefProperty): array
    {
        return \array_map(
            fn ($object) => $object->getRef(),
            $listOfObjectsWithRefProperty
        );
    }
}
static::assertCount(2, $detailTabs[0]->getCards());
            static::assertEquals('firstTab', $detailTabs[0]->getName());
            static::assertCount(2, $detailTabs[1]->getCards());
            static::assertEquals('secondTab', $detailTabs[1]->getName());

            $exampleCards = $detailTabs[1]->getCards();
            static::assertCount(2, $exampleCards);
            static::assertEquals('testWithAll', $exampleCards[0]->getName());

            $exampleCardFields = $exampleCards[0]->getFields();
            static::assertCount(4, $exampleCardFields);
            static::assertEquals('test_string', $exampleCardFields[0]->getRef());
            static::assertEquals('test_text', $exampleCardFields[1]->getRef());
            static::assertEquals('test_int', $exampleCardFields[2]->getRef());
            static::assertEquals('test_float', $exampleCardFields[3]->getRef());
        }
    }

    public function testEnrichAdminUiUnaffectedEntities(): void
    {
        static::assertCount(4, $this->customEntities);

        foreach ($this->customEntities as $entity) {
            
$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());
    }

    public static function provider(): \Generator
    {
        yield 'is hidden' => ['hidden' => 'true', 'result' => true];
        yield 'is visible' => ['hidden' => 'false', 'result' => false];
        yield 'is undefined' => ['hidden' => null, 'result' => false];
    }
}
Home | Imprint | This part of the site doesn't use cookies.