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
|
@ -8,4 +8,8 @@ use Drupal\opdavies_blog\Entity\Node\Post;
|
||||||
|
|
||||||
final class ConvertPostToTweet {
|
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
|
#AutomatedTesting #DDEV #Drupal #Drupal8 #PHP
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
$this->assertSame($expected, $post->toTweet());
|
$this->assertSame($expected, ($this->convertPostToTweet)($post));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
|
@ -79,7 +79,7 @@ final class PostTest extends EntityKernelTestBase {
|
||||||
#Drupal #PHP
|
#Drupal #PHP
|
||||||
EOF;
|
EOF;
|
||||||
|
|
||||||
$this->assertSame($expected, $post->toTweet());
|
$this->assertSame($expected, ($this->convertPostToTweet)($post));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp() {
|
||||||
|
|
Loading…
Reference in a new issue