4l: Expect a custom Post class to be returned
This commit is contained in:
parent
290c8fbcba
commit
9aec327945
5
web/modules/custom/my_module/src/Entity/Post.php
Normal file
5
web/modules/custom/my_module/src/Entity/Post.php
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\my_module\Entity;
|
||||||
|
|
||||||
|
class Post {}
|
|
@ -4,6 +4,7 @@ namespace Drupal\Tests\my_module\Kernel;
|
||||||
|
|
||||||
use Drupal\Core\Datetime\DrupalDateTime;
|
use Drupal\Core\Datetime\DrupalDateTime;
|
||||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||||
|
use Drupal\my_module\Entity\Post;
|
||||||
use Drupal\my_module\Repository\ArticleRepository;
|
use Drupal\my_module\Repository\ArticleRepository;
|
||||||
use Drupal\node\NodeInterface;
|
use Drupal\node\NodeInterface;
|
||||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||||
|
@ -23,9 +24,8 @@ class ArticleRepositoryTest extends EntityKernelTestBase {
|
||||||
|
|
||||||
$this->assertCount(1, $articles);
|
$this->assertCount(1, $articles);
|
||||||
$this->assertIsObject($articles[1]);
|
$this->assertIsObject($articles[1]);
|
||||||
$this->assertInstanceOf(NodeInterface::class, $articles[1]);
|
$this->assertInstanceOf(Post::class, $articles[1]);
|
||||||
$this->assertSame('article', $articles[1]->bundle());
|
$this->assertSame('Test post', $articles[1]->getTitle());
|
||||||
$this->assertSame('Test post', $articles[1]->label());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
|
|
Loading…
Reference in a new issue