Add a test for converting a post to a tweet

References #24
This commit is contained in:
Oliver Davies 2020-09-04 10:53:19 +01:00
parent b77c301d8c
commit 150c974040

View file

@ -6,6 +6,7 @@ namespace Drupal\Tests\custom\Kernel\Entity\Node;
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
use Drupal\opdavies_blog\Entity\Node\Post;
final class PostTest extends EntityKernelTestBase {
@ -38,6 +39,25 @@ final class PostTest extends EntityKernelTestBase {
$this->assertTrue($post->hasTweet());
}
/** @test */
public function it_converts_a_post_to_a_tweet(): void {
/** @var Post $post */
$post = Node::create([
'status' => NodeInterface::PUBLISHED,
'title' => 'Creating a custom PHPUnit command for DDEV',
'type' => 'post',
]);
$post->save();
$expected = <<<EOF
Creating a custom PHPUnit command for DDEV
http://localhost/node/1
EOF;
$this->assertSame($expected, $post->toTweet());
}
protected function setUp() {
parent::setUp();