class SortTest

Tests that the dictionary.txt file is properly sorted.

@group cspell

Hierarchy

  • class \Drupal\Tests\CSpell\SortTest extends \PHPUnit\Framework\TestCase

Expanded class hierarchy of SortTest

File

core/tests/Drupal/Tests/CSpell/SortTest.php, line 14

Namespace

Drupal\Tests\CSpell
View source
class SortTest extends TestCase {
  
  /**
   * The path to the dictionary file.
   */
  private string $filePath;
  
  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    $this->filePath = dirname(__DIR__, 5) . '/core/misc/cspell/dictionary.txt';
  }
  
  /**
   * Tests that the file exists.
   */
  public function testFileExists() : void {
    $this->assertFileExists($this->filePath);
  }
  
  /**
   * Tests that the file is properly sorted.
   */
  public function testSorted() : void {
    $content = file_get_contents($this->filePath);
    $this->assertIsString($content);
    $current_dictionary = explode("\n", rtrim($content));
    $this->assertIsArray($current_dictionary);
    $sorted_dictionary = $current_dictionary;
    sort($current_dictionary);
    $this->assertSame($current_dictionary, $sorted_dictionary);
  }

}

Members

Title Sort descending Modifiers Object type Summary
SortTest::$filePath private property The path to the dictionary file.
SortTest::setUp protected function
SortTest::testFileExists public function Tests that the file exists.
SortTest::testSorted public function Tests that the file is properly sorted.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.