Add public constants for field names
Make it easier and safer when referencing field names by adding public constants for them to the Talk and Post classes.
This commit is contained in:
parent
3025ab0f68
commit
06c3da1880
8 changed files with 28 additions and 17 deletions
|
@ -5,6 +5,7 @@ declare(strict_types=1);
|
|||
namespace Drupal\Tests\custom\Kernel\Entity\Node;
|
||||
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\opdavies_blog\Entity\Node\Post;
|
||||
use Drupal\opdavies_blog_test\Factory\PostFactory;
|
||||
|
||||
final class PostTest extends EntityKernelTestBase {
|
||||
|
@ -30,7 +31,7 @@ final class PostTest extends EntityKernelTestBase {
|
|||
|
||||
$this->assertFalse($post->hasTweet());
|
||||
|
||||
$post = (new PostFactory())->create(['field_has_tweet' => TRUE]);
|
||||
$post = (new PostFactory())->create([Post::FIELD_HAS_TWEET => TRUE]);
|
||||
$post->save();
|
||||
|
||||
$this->assertTrue($post->hasTweet());
|
||||
|
|
|
@ -42,8 +42,8 @@ final class ReorderBlogTagsTest extends EntityKernelTestBase {
|
|||
$this->createTerm($vocabulary, ['name' => 'Symfony']);
|
||||
|
||||
$post = $this->createNode([
|
||||
'field_tags' => [3, 1, 2],
|
||||
'type' => 'post',
|
||||
Post::FIELD_TAGS => [3, 1, 2],
|
||||
]);
|
||||
|
||||
/** @var Post $post */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue