test element youtube url

This commit is contained in:
Yisroel Baum 2026-05-27 20:36:34 +03:00
parent 8a06f5a57c
commit f9c4d72e60
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
6 changed files with 75 additions and 0 deletions

View file

@ -15,6 +15,8 @@ class ElementsEndpointTest extends TestCase
public function testReturnsElementTitle(): void public function testReturnsElementTitle(): void
{ {
$sampleYoutubeUrl = 'https://www.youtube.com/watch?v='
. 'yHx-r4p6hHU&t=1s';
$setRepository = app(SetRepository::class); $setRepository = app(SetRepository::class);
$elementRepository = app(ElementRepository::class); $elementRepository = app(ElementRepository::class);
$set = $setRepository->create(new CreateSetDto( $set = $setRepository->create(new CreateSetDto(
@ -28,6 +30,7 @@ class ElementsEndpointTest extends TestCase
description: 'A structured path for growth', description: 'A structured path for growth',
richText: '<p>A structured path for growth</p>', richText: '<p>A structured path for growth</p>',
pdfPath: '/assets/pdfs/baderech.pdf', pdfPath: '/assets/pdfs/baderech.pdf',
youtubeUrl: $sampleYoutubeUrl,
parentElement: null, parentElement: null,
)); ));
$firstChildElement = $elementRepository->create(new CreateElementDto( $firstChildElement = $elementRepository->create(new CreateElementDto(
@ -36,6 +39,7 @@ class ElementsEndpointTest extends TestCase
description: 'Foundations for steady avodah', description: 'Foundations for steady avodah',
richText: '<p>Foundations rich text</p>', richText: '<p>Foundations rich text</p>',
pdfPath: '/assets/pdfs/foundations.pdf', pdfPath: '/assets/pdfs/foundations.pdf',
youtubeUrl: null,
parentElement: $element, parentElement: $element,
)); ));
$secondChildElement = $elementRepository->create(new CreateElementDto( $secondChildElement = $elementRepository->create(new CreateElementDto(
@ -44,6 +48,7 @@ class ElementsEndpointTest extends TestCase
description: 'Daily practices for growth', description: 'Daily practices for growth',
richText: '<p>Daily practice rich text</p>', richText: '<p>Daily practice rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElement: $element, parentElement: $element,
)); ));
@ -69,6 +74,7 @@ class ElementsEndpointTest extends TestCase
'description' => 'A structured path for growth', 'description' => 'A structured path for growth',
'richText' => '<p>A structured path for growth</p>', 'richText' => '<p>A structured path for growth</p>',
'pdfPath' => '/assets/pdfs/baderech.pdf', 'pdfPath' => '/assets/pdfs/baderech.pdf',
'youtubeUrl' => $sampleYoutubeUrl,
], ],
]); ]);
} }

View file

@ -34,6 +34,7 @@ class SetsEndpointTest extends TestCase
description: $baderechSet->getDescription(), description: $baderechSet->getDescription(),
richText: '', richText: '',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElement: null, parentElement: null,
) )
); );

View file

@ -32,6 +32,7 @@ class ElementControllerTest extends TestCase
'A structured path for growth', 'A structured path for growth',
'<p>A structured path for growth</p>', '<p>A structured path for growth</p>',
'/assets/pdfs/baderech.pdf', '/assets/pdfs/baderech.pdf',
'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
null, null,
); );
$firstChildElement = $this->createElement( $firstChildElement = $this->createElement(
@ -40,6 +41,7 @@ class ElementControllerTest extends TestCase
'Foundations for steady avodah', 'Foundations for steady avodah',
'<p>Foundations rich text</p>', '<p>Foundations rich text</p>',
'/assets/pdfs/foundations.pdf', '/assets/pdfs/foundations.pdf',
null,
$element, $element,
); );
$secondChildElement = $this->createElement( $secondChildElement = $this->createElement(
@ -48,6 +50,7 @@ class ElementControllerTest extends TestCase
'Daily practices for growth', 'Daily practices for growth',
'<p>Daily practice rich text</p>', '<p>Daily practice rich text</p>',
null, null,
null,
$element, $element,
); );
@ -69,6 +72,10 @@ class ElementControllerTest extends TestCase
'/assets/pdfs/baderech.pdf', '/assets/pdfs/baderech.pdf',
$body['element']['pdfPath'], $body['element']['pdfPath'],
); );
$this->assertSame(
'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
$body['element']['youtubeUrl'],
);
$this->assertSame([ $this->assertSame([
[ [
'id' => $firstChildElement->getId(), 'id' => $firstChildElement->getId(),
@ -121,6 +128,7 @@ class ElementControllerTest extends TestCase
string $description, string $description,
string $richText, string $richText,
?string $pdfPath, ?string $pdfPath,
?string $youtubeUrl,
?Element $parentElement, ?Element $parentElement,
): Element { ): Element {
return $this->elementRepo->create(new CreateElementDto( return $this->elementRepo->create(new CreateElementDto(
@ -129,6 +137,7 @@ class ElementControllerTest extends TestCase
description: $description, description: $description,
richText: $richText, richText: $richText,
pdfPath: $pdfPath, pdfPath: $pdfPath,
youtubeUrl: $youtubeUrl,
parentElement: $parentElement, parentElement: $parentElement,
)); ));
} }

View file

@ -22,6 +22,7 @@ class ElementTest extends TestCase
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
set: $set, set: $set,
parentElement: null, parentElement: null,
); );
@ -31,6 +32,7 @@ class ElementTest extends TestCase
description: 'Child description', description: 'Child description',
richText: '<p>Child rich text</p>', richText: '<p>Child rich text</p>',
pdfPath: '/assets/pdfs/child.pdf', pdfPath: '/assets/pdfs/child.pdf',
youtubeUrl: 'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
set: $set, set: $set,
parentElement: $rootElement, parentElement: $rootElement,
); );
@ -49,9 +51,14 @@ class ElementTest extends TestCase
'/assets/pdfs/child.pdf', '/assets/pdfs/child.pdf',
$childElement->getPdfPath(), $childElement->getPdfPath(),
); );
$this->assertSame(
'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
$childElement->getYoutubeUrl(),
);
$this->assertSame($set, $childElement->getSet()); $this->assertSame($set, $childElement->getSet());
$this->assertSame($rootElement, $childElement->getParentElement()); $this->assertSame($rootElement, $childElement->getParentElement());
$this->assertNull($rootElement->getPdfPath()); $this->assertNull($rootElement->getPdfPath());
$this->assertNull($rootElement->getYoutubeUrl());
$this->assertNull($rootElement->getParentElement()); $this->assertNull($rootElement->getParentElement());
} }
} }

View file

@ -50,6 +50,7 @@ class CreateElementTest extends TestCase
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: '/assets/pdfs/root.pdf', pdfPath: '/assets/pdfs/root.pdf',
youtubeUrl: 'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
parentElementId: null, parentElementId: null,
)); ));
@ -58,6 +59,10 @@ class CreateElementTest extends TestCase
$this->assertSame('Root description', $element->getDescription()); $this->assertSame('Root description', $element->getDescription());
$this->assertSame('<p>Root rich text</p>', $element->getRichText()); $this->assertSame('<p>Root rich text</p>', $element->getRichText());
$this->assertSame('/assets/pdfs/root.pdf', $element->getPdfPath()); $this->assertSame('/assets/pdfs/root.pdf', $element->getPdfPath());
$this->assertSame(
'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
$element->getYoutubeUrl(),
);
$this->assertSame($set->getId(), $element->getSet()->getId()); $this->assertSame($set->getId(), $element->getSet()->getId());
$this->assertNull($element->getParentElement()); $this->assertNull($element->getParentElement());
} }
@ -72,6 +77,7 @@ class CreateElementTest extends TestCase
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: null, parentElementId: null,
) )
); );
@ -83,6 +89,7 @@ class CreateElementTest extends TestCase
description: 'Child description', description: 'Child description',
richText: '<p>Child rich text</p>', richText: '<p>Child rich text</p>',
pdfPath: '/assets/pdfs/child.pdf', pdfPath: '/assets/pdfs/child.pdf',
youtubeUrl: 'https://youtu.be/yHx-r4p6hHU',
parentElementId: $rootElement->getId(), parentElementId: $rootElement->getId(),
) )
); );
@ -100,6 +107,10 @@ class CreateElementTest extends TestCase
'/assets/pdfs/child.pdf', '/assets/pdfs/child.pdf',
$childElement->getPdfPath(), $childElement->getPdfPath(),
); );
$this->assertSame(
'https://youtu.be/yHx-r4p6hHU',
$childElement->getYoutubeUrl(),
);
$this->assertSame( $this->assertSame(
$rootElement->getId(), $rootElement->getId(),
$childElement->getParentElement()->getId(), $childElement->getParentElement()->getId(),
@ -116,12 +127,14 @@ class CreateElementTest extends TestCase
description: null, description: null,
richText: null, richText: null,
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: null, parentElementId: null,
)); ));
$this->assertSame('', $element->getDescription()); $this->assertSame('', $element->getDescription());
$this->assertSame('', $element->getRichText()); $this->assertSame('', $element->getRichText());
$this->assertNull($element->getPdfPath()); $this->assertNull($element->getPdfPath());
$this->assertNull($element->getYoutubeUrl());
} }
public function testCreatesElementWithNullPdfPathWhenBlank(): void public function testCreatesElementWithNullPdfPathWhenBlank(): void
@ -134,12 +147,30 @@ class CreateElementTest extends TestCase
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: '', pdfPath: '',
youtubeUrl: null,
parentElementId: null, parentElementId: null,
)); ));
$this->assertNull($element->getPdfPath()); $this->assertNull($element->getPdfPath());
} }
public function testCreatesElementWithNullYoutubeUrlWhenBlank(): void
{
$set = $this->createSet('Daily learning');
$element = $this->createElement->execute(new CreateElementRequest(
setId: $set->getId(),
title: 'Root',
description: 'Root description',
richText: '<p>Root rich text</p>',
pdfPath: null,
youtubeUrl: '',
parentElementId: null,
));
$this->assertNull($element->getYoutubeUrl());
}
public function testThrowsWhenSetIdMissing(): void public function testThrowsWhenSetIdMissing(): void
{ {
$this->expectException(BadRequestException::class); $this->expectException(BadRequestException::class);
@ -151,6 +182,7 @@ class CreateElementTest extends TestCase
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: null, parentElementId: null,
)); ));
} }
@ -166,6 +198,7 @@ class CreateElementTest extends TestCase
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: null, parentElementId: null,
)); ));
} }
@ -181,6 +214,7 @@ class CreateElementTest extends TestCase
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: null, parentElementId: null,
)); ));
} }
@ -200,6 +234,7 @@ class CreateElementTest extends TestCase
description: 'Child description', description: 'Child description',
richText: '<p>Child rich text</p>', richText: '<p>Child rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: 99, parentElementId: 99,
)); ));
} }
@ -213,6 +248,7 @@ class CreateElementTest extends TestCase
description: 'Root description', description: 'Root description',
richText: '<p>Root rich text</p>', richText: '<p>Root rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: null, parentElementId: null,
)); ));
@ -227,6 +263,7 @@ class CreateElementTest extends TestCase
description: 'Another root description', description: 'Another root description',
richText: '<p>Another root rich text</p>', richText: '<p>Another root rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: null, parentElementId: null,
)); ));
} }
@ -242,6 +279,7 @@ class CreateElementTest extends TestCase
description: 'Parent root description', description: 'Parent root description',
richText: '<p>Parent root rich text</p>', richText: '<p>Parent root rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: null, parentElementId: null,
) )
); );
@ -257,6 +295,7 @@ class CreateElementTest extends TestCase
description: 'Invalid child description', description: 'Invalid child description',
richText: '<p>Invalid child rich text</p>', richText: '<p>Invalid child rich text</p>',
pdfPath: null, pdfPath: null,
youtubeUrl: null,
parentElementId: $parentElement->getId(), parentElementId: $parentElement->getId(),
)); ));
} }

View file

@ -33,6 +33,7 @@ class GetElementTest extends TestCase
'A structured path for growth', 'A structured path for growth',
'<p>A structured path for growth</p>', '<p>A structured path for growth</p>',
'/assets/pdfs/baderech.pdf', '/assets/pdfs/baderech.pdf',
'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
null, null,
); );
@ -56,6 +57,10 @@ class GetElementTest extends TestCase
'/assets/pdfs/baderech.pdf', '/assets/pdfs/baderech.pdf',
$foundElement->getPdfPath(), $foundElement->getPdfPath(),
); );
$this->assertSame(
'https://www.youtube.com/watch?v=yHx-r4p6hHU&t=1s',
$foundElement->getYoutubeUrl(),
);
} }
public function testReturnsDirectChildElements(): void public function testReturnsDirectChildElements(): void
@ -68,6 +73,7 @@ class GetElementTest extends TestCase
'<p>A structured path for growth</p>', '<p>A structured path for growth</p>',
'/assets/pdfs/baderech.pdf', '/assets/pdfs/baderech.pdf',
null, null,
null,
); );
$firstChildElement = $this->createElement( $firstChildElement = $this->createElement(
$set, $set,
@ -75,6 +81,7 @@ class GetElementTest extends TestCase
'Foundations for steady avodah', 'Foundations for steady avodah',
'<p>Foundations rich text</p>', '<p>Foundations rich text</p>',
'/assets/pdfs/foundations.pdf', '/assets/pdfs/foundations.pdf',
null,
$parentElement, $parentElement,
); );
$secondChildElement = $this->createElement( $secondChildElement = $this->createElement(
@ -83,6 +90,7 @@ class GetElementTest extends TestCase
'Daily practices for growth', 'Daily practices for growth',
'<p>Daily practice rich text</p>', '<p>Daily practice rich text</p>',
null, null,
null,
$parentElement, $parentElement,
); );
$this->createElement( $this->createElement(
@ -91,6 +99,7 @@ class GetElementTest extends TestCase
'Nested description', 'Nested description',
'<p>Nested rich text</p>', '<p>Nested rich text</p>',
null, null,
null,
$firstChildElement, $firstChildElement,
); );
$otherSet = $this->createSet(2, 'Daily Learning'); $otherSet = $this->createSet(2, 'Daily Learning');
@ -101,6 +110,7 @@ class GetElementTest extends TestCase
'<p>Other parent rich text</p>', '<p>Other parent rich text</p>',
null, null,
null, null,
null,
); );
$this->createElement( $this->createElement(
$otherSet, $otherSet,
@ -108,6 +118,7 @@ class GetElementTest extends TestCase
'Other child description', 'Other child description',
'<p>Other child rich text</p>', '<p>Other child rich text</p>',
null, null,
null,
$otherParentElement, $otherParentElement,
); );
@ -169,6 +180,7 @@ class GetElementTest extends TestCase
string $description, string $description,
string $richText, string $richText,
?string $pdfPath, ?string $pdfPath,
?string $youtubeUrl,
?Element $parentElement, ?Element $parentElement,
): Element { ): Element {
return $this->elementRepo->create(new CreateElementDto( return $this->elementRepo->create(new CreateElementDto(
@ -177,6 +189,7 @@ class GetElementTest extends TestCase
description: $description, description: $description,
richText: $richText, richText: $richText,
pdfPath: $pdfPath, pdfPath: $pdfPath,
youtubeUrl: $youtubeUrl,
parentElement: $parentElement, parentElement: $parentElement,
)); ));
} }