Skip to content

Commit

Permalink
Reorganize some Gdn_Format test fixtures
Browse files Browse the repository at this point in the history
  • Loading branch information
initvector committed Jan 18, 2019
1 parent ecbd849 commit 704b934
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 105 deletions.
104 changes: 0 additions & 104 deletions tests/Library/Core/GdnFormatTest.php

This file was deleted.

65 changes: 65 additions & 0 deletions tests/Library/Vanilla/Formatting/GdnFormatTest.php
Expand Up @@ -7,6 +7,7 @@

namespace VanillaTests\Library\Vanilla\Formatting\Quill;

use Vanilla\Formatting\Formats\RichFormat;
use VanillaTests\Library\Vanilla\Formatting\FixtureRenderingTestCase;

/**
Expand Down Expand Up @@ -136,6 +137,70 @@ public function provideHtmlToHtml(): array {
return $this->createFixtureDataProvider('/formats/html/html');
}

/**
* Test results of Gdn_Format::excerpt with rich-formatted content.
*
* @param string $fixtureDir The directory of the fixture to use for the testCase.
* @dataProvider provideRichExcerpts
*/
public function testRichExcerpt(string $fixtureDir) {
list($body, $expected) = $this->getFixture(self::FIXTURE_DIR . "/rich/excerpt/" . $fixtureDir);
$actual = \Gdn_Format::excerpt($body, RichFormat::FORMAT_KEY);
$this->assertEquals(
$expected,
$actual,
"Expected excerpt outputs for fixture $fixtureDir did not match."
);
}

/**
* Provide data for testing the excerpt method with the rich format.
*
* @return array
*/
public function provideRichExcerpts(): array {
return $this->createFixtureDataProvider("/formats/rich/excerpt");
}

/**
* Test results of Gdn_Format::plainText with rich-formatted content.
*
* @param string $fixtureDir The directory of the fixture to use for the testCase.
* @dataProvider provideRichPlainText
*/
public function testRichPlainText(string $fixtureDir) {
list($body, $expected) = $this->getFixture(self::FIXTURE_DIR . "/rich/plain-text/" . $fixtureDir);
$actual = \Gdn_Format::plainText($body, RichFormat::FORMAT_KEY);
$this->assertEquals(
$expected,
$actual,
"Expected excerpt outputs for fixture $fixtureDir did not match."
);
}

/**
* Provide data for testing the plainText method.
*
* @return array
*/
public function provideRichPlainText(): array {
return $this->createFixtureDataProvider("/formats/rich/plain-text");
}

/**
* Test using a rich-format array of operations with the quoteEmbed method.
*/
public function testRichQuoteEmbedAsArray() {
$richEmbed = [
["insert" => "Hello world."]
];

$this->assertEquals(
"<p>Hello world.</p>",
\Gdn_Format::quoteEmbed($richEmbed, RichFormat::FORMAT_KEY)
);
}

/**
* Test the wysiwyg HTML rendering.
*
Expand Down
Expand Up @@ -48,4 +48,4 @@
{
"insert": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\n"
}
]
]
@@ -0,0 +1 @@
https://vanillaforums.example/discussion/comment/1#Comment_1 This is a spoiler. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute…
@@ -0,0 +1,5 @@
[
{
"insert": "Hello world.\n"
}
]
@@ -0,0 +1 @@
Hello world.

0 comments on commit 704b934

Please sign in to comment.