Use convertPostToTweet within the test

Use the convertPostToTweet action within the tests rather than calling
the toTweet() method, and delegate the Action to using the toTweet()
functionality.
This commit is contained in:
Oliver Davies 2021-04-21 00:13:54 +01:00
parent 23cc7cec2d
commit 9d1cbdeffd
2 changed files with 6 additions and 2 deletions

View file

@ -8,4 +8,8 @@ use Drupal\opdavies_blog\Entity\Node\Post;
final class ConvertPostToTweet {
public function __invoke(Post $post): string {
return $post->toTweet();
}
}

View file

@ -59,7 +59,7 @@ final class PostTest extends EntityKernelTestBase {
#AutomatedTesting #DDEV #Drupal #Drupal8 #PHP
EOF;
$this->assertSame($expected, $post->toTweet());
$this->assertSame($expected, ($this->convertPostToTweet)($post));
}
/** @test */
@ -79,7 +79,7 @@ final class PostTest extends EntityKernelTestBase {
#Drupal #PHP
EOF;
$this->assertSame($expected, $post->toTweet());
$this->assertSame($expected, ($this->convertPostToTweet)($post));
}
protected function setUp() {