Add initial PresentationCounter logic
This commit is contained in:
parent
bf8017c477
commit
1fe63e7326
4 changed files with 69 additions and 0 deletions
5
modules/opd_presentations/opd_presentations.info.yml
Normal file
5
modules/opd_presentations/opd_presentations.info.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
name: Presentations
|
||||||
|
description: Custom functionality for presentations.
|
||||||
|
core_version_requirement: ^11
|
||||||
|
type: module
|
||||||
|
package: Custom
|
2
modules/opd_presentations/opd_presentations.services.yml
Normal file
2
modules/opd_presentations/opd_presentations.services.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
services:
|
||||||
|
Drupal\opd_presentations\PresentationCounter: {}
|
13
modules/opd_presentations/src/PresentationCounter.php
Normal file
13
modules/opd_presentations/src/PresentationCounter.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Drupal\opd_presentations;
|
||||||
|
|
||||||
|
final class PresentationCounter {
|
||||||
|
|
||||||
|
public function getCount(): int {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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