docs: DrupalCon updates
This commit is contained in:
parent
6cf7d0fee4
commit
675e89e9d1
28 changed files with 1240 additions and 144 deletions
49
test-driven-drupal/code/15.txt
Normal file
49
test-driven-drupal/code/15.txt
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\drupalcon\Kernel;
|
||||
|
||||
use Drupal\drupalcon\Repository\ArticleRepository;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
|
||||
class ArticleRepositoryTest extends EntityKernelTestBase {
|
||||
|
||||
use NodeCreationTrait;
|
||||
|
||||
public static $modules = [
|
||||
'drupalcon',
|
||||
'node',
|
||||
];
|
||||
|
||||
/** @test */
|
||||
public function it_returns_blog_posts() {
|
||||
// start test
|
||||
$this->createNode([
|
||||
'title' => 'Test post',
|
||||
'type' => 'article',
|
||||
]);
|
||||
|
||||
$repository = $this->container->get(ArticleRepository::class);
|
||||
|
||||
$articles = $repository->getAll();
|
||||
|
||||
$this->assertCount(1, $articles);
|
||||
$this->assertIsObject($articles[1]);
|
||||
|
||||
$this->assertInstanceOf(NodeInterface::class, $articles[1]);
|
||||
$this->assertSame('article', $articles[1]->bundle());
|
||||
$this->assertSame('Test post', $articles[1]->label());
|
||||
// end test
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
---
|
||||
|
||||
Article Repository (Drupal\Tests\drupalcon\Kernel\ArticleRepository)
|
||||
✔ It returns blog posts
|
||||
|
||||
Time: 00:00.449, Memory: 6.00 MB
|
||||
|
||||
OK (1 test, 15 assertions)
|
Loading…
Add table
Add a link
Reference in a new issue