You are here

public function ResponseTest::dataProvider in Minify Source HTML 8

Set of cases with expected results.

See Cases controller for test input data.

Return value

array Test cases.

See also

\Drupal\minifyhtml_test\Controller\Cases::item()

File

tests/src/Functional/ResponseTest.php, line 49

Class

ResponseTest
Class ResponseTest.

Namespace

Drupal\Tests\minifyhtml\Functional

Code

public function dataProvider() {
  $data = [];

  // Test Minify HTML Textarea Replacement.
  $expected_output = "<html><head><title>Test HTML</title></head><body><textarea cols=\"55\" rows=\"31\">\n";
  $expected_output .= "Content in here will not matter.\n";
  $expected_output .= "Even multiline content.\n";
  $expected_output .= "</textarea></body></html>";
  $case = 'textarea_replacement';
  $data[$case] = [
    $case,
    $expected_output,
  ];

  // Test Minify HTML Pre Replacement.
  $expected_output = "<html><head><title>Test HTML</title></head><body><pre>\n";
  $expected_output .= "  Indented content.\n";
  $expected_output .= "         Weirdly Indented content.\n";
  $expected_output .= "Non-indented content.\n";
  $expected_output .= "</pre></body></html>";
  $case = 'pre_replacement';
  $data[$case] = [
    $case,
    $expected_output,
  ];

  // Test Minify HTML Iframe Replacement.
  $case = 'iframe_replacement';
  $data[$case] = [
    $case,
    "<html><head><title>Test HTML</title></head><body><iframe src=\"\" width=\"100\" height=\"100\" ></iframe></body></html>",
  ];

  // Test Minify HTML Script Replacement.
  $expected_output = "<html><head><title>Test HTML</title></head><body><script>\n";
  $expected_output .= "alert('test');\n";
  $expected_output .= "</script></body></html>";
  $case = 'script_replacement';
  $data[$case] = [
    $case,
    $expected_output,
  ];

  // Test Minify HTML Style Replacement.
  $expected_output = "<html><head><title>Test HTML</title></head><body><style>\n";
  $expected_output .= "body { color: #fff; }\n";
  $expected_output .= "</style></body></html>";
  $case = 'style_replacement';
  $data[$case] = [
    $case,
    $expected_output,
  ];

  // Test Minify HTML Comment Stripping.
  $case = 'comment_stripping';
  $data[$case] = [
    $case,
    "<html><head><title>Test HTML</title></head><body></body></html>",
  ];
  return $data;
}