![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/setup/src/Magento/Setup/Test/Unit/Model/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Setup\Test\Unit\Model; use Magento\Setup\Model\Dictionary; use PHPUnit\Framework\TestCase; class DictionaryTest extends TestCase { /** * @var array */ private $dictionary = [ 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'sed', 'do', 'eiusmod', 'tempor', 'incididunt', 'ut', 'labore', 'et', 'dolore', 'magna', 'aliqua' ]; public function testDictionaryFileNotFoundException() { $this->expectException('Magento\Setup\Exception'); $this->expectExceptionMessage('Description file some-wrong-file.csv not found or is not readable'); $dictionary = new Dictionary('some-wrong-file.csv'); $dictionary->getRandWord(); } public function testDictionaryFileIsEmptyException() { $this->expectException('Magento\Setup\Exception'); $this->expectExceptionMessageMatches('/Dictionary file .*empty-dictionary\.csv is empty/'); $filePath = __DIR__ . '/_files/empty-dictionary.csv'; file_put_contents($filePath, ''); try { $dictionary = new Dictionary($filePath); $dictionary->getRandWord(); } finally { unlink($filePath); } } public function testGetRandWord() { $filePath = __DIR__ . '/_files/valid-dictionary.csv'; file_put_contents($filePath, implode(PHP_EOL, $this->dictionary)); $dictionary = new Dictionary($filePath); $this->assertContains($dictionary->getRandWord(), $this->dictionary); $this->assertContains($dictionary->getRandWord(), $this->dictionary); $this->assertContains($dictionary->getRandWord(), $this->dictionary); unlink($filePath); } }