Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ItalicMixinTest.php
Go to the documentation of this file.
1 <?php
7 
8 class ItalicMixinTest extends \PHPUnit\Framework\TestCase
9 {
13  private $mixin;
14 
18  private $randomWordSelectorMock;
19 
23  private $wordWrapperMock;
24 
25  public function setUp()
26  {
27  $this->randomWordSelectorMock =
28  $this->createMock(\Magento\Setup\Model\Description\Mixin\Helper\RandomWordSelector::class);
29  $this->wordWrapperMock = $this->createMock(\Magento\Setup\Model\Description\Mixin\Helper\WordWrapper::class);
30 
31  $this->mixin = new \Magento\Setup\Model\Description\Mixin\ItalicMixin(
32  $this->randomWordSelectorMock,
33  $this->wordWrapperMock
34  );
35  }
36 
37  public function testEmptyApply()
38  {
39  $this->assertEquals('', $this->mixin->apply(''));
40  }
41 
42  public function testApply()
43  {
44  $fixtureString = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.';
45  $fixtureStringResult = '<i>Lorem</i> ipsum <i>dolor</i> sit amet, consectetur adipiscing elit.';
46  $randWordsFixture = ['Lorem', 'dolor'];
47 
48  $this->randomWordSelectorMock
49  ->expects($this->once())
50  ->method('getRandomWords')
51  ->with($this->equalTo($fixtureString), $this->greaterThan(0))
52  ->willReturn($randWordsFixture);
53 
54  $this->wordWrapperMock
55  ->expects($this->once())
56  ->method('wrapWords')
57  ->with($fixtureString, $randWordsFixture, '<i>%s</i>')
58  ->willReturn($fixtureStringResult);
59 
60  $this->assertEquals($fixtureStringResult, $this->mixin->apply($fixtureString));
61  }
62 }