hl = new \Highlight\Highlighter(); } public function testGetAvailableStyleSheets_NamesOnly() { $results = \HighlightUtilities\getAvailableStyleSheets(); $this->assertNotEmpty($results); foreach ($results as $result) { $this->assertNotContains(DIRECTORY_SEPARATOR, $result); $this->assertNotContains(".css", $result); } } public function testGetAvailableStyleSheets_FilePaths() { $results = \HighlightUtilities\getAvailableStyleSheets(true); $this->assertNotEmpty($results); foreach ($results as $result) { $this->assertContains(DIRECTORY_SEPARATOR, $result); $this->assertContains(".css", $result); $this->assertFileExists($result); } } public function testGetAvailableStyleSheets_SameCount() { $namesOnly = \HighlightUtilities\getAvailableStyleSheets(); $filePaths = \HighlightUtilities\getAvailableStyleSheets(true); $this->assertCount(count($namesOnly), $filePaths); } public function testGetStyleSheet_Exists() { $yesExt = \HighlightUtilities\getStyleSheet("a11y-dark.css"); $noExt = \HighlightUtilities\getStyleSheet("a11y-dark"); $this->assertNotEmpty($yesExt); $this->assertEquals($yesExt, $noExt); } public function testGetStyleSheet_NotExists() { $this->setExpectedException('\DomainException'); \HighlightUtilities\getStyleSheet("strawberry.png"); } public function testSplitCodeIntoArray_MultilineComment() { $raw = <<hl->highlight('php', $raw); $cleanSplit = \HighlightUtilities\splitCodeIntoArray($highlighted->value); $dumbSplit = preg_split('/\R/', $highlighted->value); $this->assertEquals(1, substr_count($highlighted->value, 'hljs-comment')); $this->assertEquals(count($cleanSplit), substr_count(implode(PHP_EOL, $cleanSplit), 'hljs-comment')); $this->assertTrue(is_array($cleanSplit)); $this->assertCount(count($dumbSplit), $cleanSplit); $this->assertNotEquals($cleanSplit, $dumbSplit); foreach ($cleanSplit as $line) { $this->assertStringStartsWith('', trim($line)); $this->assertStringEndsWith('', trim($line)); } } public function testGetThemeBackgroundColorSingleColor() { $theme = 'atom-one-dark'; $this->assertEquals(array('r' => 40, 'g' => 44, 'b' => 52), \HighlightUtilities\getThemeBackgroundColor($theme)); } public function testGetThemeBackgroundColorColorWithBgImage() { $theme = 'brown-paper'; $this->assertEquals(array('r' => 183, 'g' => 166, 'b' => 142), \HighlightUtilities\getThemeBackgroundColor($theme)); } }