Add initial PresentationCounter logic
This commit is contained in:
parent
bf8017c477
commit
1fe63e7326
4 changed files with 69 additions and 0 deletions
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Drupal\opd_presentations\Kernel;
|
||||
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\opd_presentations\PresentationCounter;
|
||||
use Drupal\paragraphs\Entity\Paragraph;
|
||||
use Drupal\paragraphs\ParagraphInterface;
|
||||
|
||||
class PresentationCounterTest extends EntityKernelTestBase {
|
||||
|
||||
use NodeCreationTrait;
|
||||
|
||||
protected static $modules = [
|
||||
'node',
|
||||
'opd_presentations',
|
||||
'paragraphs',
|
||||
];
|
||||
|
||||
public function test_count_presentation(): void {
|
||||
$this->createPresentation(
|
||||
events: [
|
||||
Paragraph::create(['type' => 'event']),
|
||||
],
|
||||
);
|
||||
|
||||
$counter = $this->container->get(PresentationCounter::class);
|
||||
|
||||
$this->assertSame(
|
||||
actual: $counter->getCount(),
|
||||
expected: 1,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ParagraphInterface[] $events
|
||||
*/
|
||||
private function createPresentation(array $events): NodeInterface {
|
||||
return $this->createNode([
|
||||
'field_events' => $events,
|
||||
'type' => 'presentation',
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue