64 lines
2 KiB
PHP
64 lines
2 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Element;
|
|
|
|
use App\Element\Element;
|
|
use App\Set\Set as DomainSet;
|
|
use Tests\TestCase;
|
|
|
|
class ElementTest extends TestCase
|
|
{
|
|
public function testCreatesElementWithNullableParent(): void
|
|
{
|
|
$set = new DomainSet(
|
|
id: 1,
|
|
name: 'Daily learning',
|
|
description: 'Daily learning description',
|
|
iconImageUrl: '/assets/daily-learning-icon.svg',
|
|
);
|
|
$rootElement = new Element(
|
|
id: 1,
|
|
title: 'Root',
|
|
description: 'Root description',
|
|
richText: '<p>Root rich text</p>',
|
|
pdfPath: null,
|
|
youtubeUrl: null,
|
|
set: $set,
|
|
parentElement: null,
|
|
);
|
|
$childElement = new Element(
|
|
id: 2,
|
|
title: 'Child',
|
|
description: 'Child description',
|
|
richText: '<p>Child rich text</p>',
|
|
pdfPath: '/assets/pdfs/child.pdf',
|
|
youtubeUrl: 'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
|
|
set: $set,
|
|
parentElement: $rootElement,
|
|
);
|
|
|
|
$this->assertSame(2, $childElement->getId());
|
|
$this->assertSame('Child', $childElement->getTitle());
|
|
$this->assertSame(
|
|
'Child description',
|
|
$childElement->getDescription(),
|
|
);
|
|
$this->assertSame(
|
|
'<p>Child rich text</p>',
|
|
$childElement->getRichText(),
|
|
);
|
|
$this->assertSame(
|
|
'/assets/pdfs/child.pdf',
|
|
$childElement->getPdfPath(),
|
|
);
|
|
$this->assertSame(
|
|
'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
|
|
$childElement->getYoutubeUrl(),
|
|
);
|
|
$this->assertSame($set, $childElement->getSet());
|
|
$this->assertSame($rootElement, $childElement->getParentElement());
|
|
$this->assertNull($rootElement->getPdfPath());
|
|
$this->assertNull($rootElement->getYoutubeUrl());
|
|
$this->assertNull($rootElement->getParentElement());
|
|
}
|
|
}
|