SortTest.php

Same filename in this branch
  1. 10 core/modules/jsonapi/tests/src/Unit/Query/SortTest.php
  2. 10 core/modules/views/tests/src/Kernel/Handler/SortTest.php
  3. 10 core/tests/Drupal/Tests/PhpCs/SortTest.php
Same filename in other branches
  1. 9 core/modules/jsonapi/tests/src/Unit/Query/SortTest.php
  2. 9 core/modules/views/tests/src/Kernel/Handler/SortTest.php
  3. 9 core/tests/Drupal/Tests/PhpCs/SortTest.php
  4. 8.9.x core/modules/jsonapi/tests/src/Unit/Query/SortTest.php
  5. 8.9.x core/modules/views/tests/src/Kernel/Handler/SortTest.php
  6. 11.x core/modules/jsonapi/tests/src/Unit/Query/SortTest.php
  7. 11.x core/modules/views/tests/src/Kernel/Handler/SortTest.php
  8. 11.x core/tests/Drupal/Tests/PhpCs/SortTest.php
  9. 11.x core/tests/Drupal/Tests/CSpell/SortTest.php

Namespace

Drupal\Tests\CSpell

File

core/tests/Drupal/Tests/CSpell/SortTest.php

View source
<?php

declare (strict_types=1);
namespace Drupal\Tests\CSpell;

use PHPUnit\Framework\TestCase;

/**
 * Tests that the dictionary.txt file is properly sorted.
 *
 * @group cspell
 */
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);
    }

}

Classes

Title Deprecated Summary
SortTest Tests that the dictionary.txt file is properly sorted.

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