diff --git a/README.md b/README.md index 913819d88..a00258637 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ Note that this only lets you check whether an error "category" popped up. It can |-------|-------------| | [`AmpBoilerplate`](https://github.com/ampproject/amp-toolbox-php/blob/main/src/Optimizer/Transformer/AmpBoilerplate.php) | Transformer that removes AMP boilerplate `' + . '' + . ' ' + . ' ' + . ' ' + . ' ' + . ' ' + . ' ' + . '' + . '', + TestMarkup::DOCTYPE . '' + . '' . TestMarkup::META_CHARSET . $ampStoryScript . '' + . $ampStoryLink + . $dvhPolyfill + . '' + . '' + . ' ' + . ' ' + . ' ' + . ' ' + . ' ' + . ' ' + . '' + . '', + [ + AmpStoryCssOptimizerConfiguration::OPTIMIZE_AMP_STORY => true, + ] + ], + 'optimize_amp_custom_css' => [ + TestMarkup::DOCTYPE . '' + . '' . TestMarkup::META_CHARSET . $ampStoryScript + . '' + . '', + TestMarkup::DOCTYPE . '' + . '' . TestMarkup::META_CHARSET . $ampStoryScript + . '' + . $ampStoryLink + . $dvhPolyfill + . '', + [ + AmpStoryCssOptimizerConfiguration::OPTIMIZE_AMP_STORY => true, + ] + ] + ]; + } + + /** + * Test the transform() method. + * + * @covers \AmpProject\Optimizer\Transformer\AmpStoryCssOptimizer::transform() + * @dataProvider dataTransform() + * + * @param string $source String of source HTML. + * @param string $expectedHtml String of expected HTML output. + * @param array $config Configuration data to use. + */ + public function testTransform($source, $expectedHtml, $config = []) + { + $document = Document::fromHtml($source); + $transformer = new AmpStoryCssOptimizer(new AmpStoryCssOptimizerConfiguration($config)); + $errors = new ErrorCollection(); + + $transformer->transform($document, $errors); + + $output = $document->saveHTML(); + + $this->assertEqualMarkup($expectedHtml, $output); + } +}