Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DescriptionSentenceGeneratorTest.php
Go to the documentation of this file.
1 <?php
7 
8 class DescriptionSentenceGeneratorTest extends \PHPUnit\Framework\TestCase
9 {
13  private $dictionaryMock;
14 
18  private $sentenceGenerator;
19 
23  private $sentenceConfig = [
24  'words' => [
25  'count-min' => 7,
26  'count-max' => 7
27  ]
28  ];
29 
30  public function setUp()
31  {
32  $this->dictionaryMock = $this->createMock(\Magento\Setup\Model\Dictionary::class);
33  $this->sentenceGenerator = new \Magento\Setup\Model\Description\DescriptionSentenceGenerator(
34  $this->dictionaryMock,
35  $this->sentenceConfig
36  );
37  }
38 
39  public function testSentenceGeneration()
40  {
41  $this->dictionaryMock
42  ->expects($this->exactly(7))
43  ->method('getRandWord')
44  ->will($this->onConsecutiveCalls(
45  'Lorem',
46  'ipsum',
47  'dolor',
48  'sit',
49  'amet',
50  'consectetur',
51  'adipiscing'
52  ));
53 
54  $this->assertEquals(
55  'Lorem ipsum dolor sit amet consectetur adipiscing.',
56  $this->sentenceGenerator->generate()
57  );
58  }
59 }