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:
parent
23cc7cec2d
commit
9d1cbdeffd
2 changed files with 6 additions and 2 deletions
web/modules/custom/blog
|
@ -8,4 +8,8 @@ use Drupal\opdavies_blog\Entity\Node\Post;
|
|||
|
||||
final class ConvertPostToTweet {
|
||||
|
||||
public function __invoke(Post $post): string {
|
||||
return $post->toTweet();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue