Test node bundle
This commit is contained in:
parent
e09fdbe5d0
commit
196b1f1517
16
web/modules/custom/example/src/PostWrapper.php
Normal file
16
web/modules/custom/example/src/PostWrapper.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\example;
|
||||
|
||||
use Drupal\node\NodeInterface;
|
||||
|
||||
final class PostWrapper {
|
||||
|
||||
public function __construct(private NodeInterface $post) {
|
||||
}
|
||||
|
||||
public function getType(): string {
|
||||
return $this->post->bundle();
|
||||
}
|
||||
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\example\Unit;
|
||||
|
||||
use Drupal\example\PostWrapper;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
|
@ -15,8 +16,12 @@ final class PostWrapperTest extends UnitTestCase {
|
|||
$node = $this->createMock(NodeInterface::class);
|
||||
$node->method('bundle')->willReturn('post');
|
||||
|
||||
$wrapper = new PostWrapper($node);
|
||||
|
||||
self::assertInstanceOf(NodeInterface::class, $node);
|
||||
self::assertSame('post', $node->bundle());
|
||||
|
||||
self::assertSame('post', $wrapper->getType());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue