diff options
author | fox <[email protected]> | 2021-08-18 07:51:19 +0300 |
---|---|---|
committer | fox <[email protected]> | 2021-08-18 07:51:19 +0300 |
commit | 28eafa2bcd6e327e7014174c4efd4c10d9491e27 (patch) | |
tree | efd9e28718eff791dcaa7ffddbac44c38deedfb8 /plugins/af_readability/vendor/fivefilters/readability.php/test/ConfigurationTest.php | |
parent | a73e3bec45c5523910c711cf882976b71781ac9e (diff) | |
parent | b6b6771d8d7dcf13938d1578099074b0123a5d5e (diff) |
Merge pull request 'pull latest readability-php via composer' (#42) from niehztog/tt-rss:update-readability into master
Reviewed-on: https://git.tt-rss.org/fox/tt-rss/pulls/42
Diffstat (limited to 'plugins/af_readability/vendor/fivefilters/readability.php/test/ConfigurationTest.php')
-rw-r--r-- | plugins/af_readability/vendor/fivefilters/readability.php/test/ConfigurationTest.php | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/plugins/af_readability/vendor/fivefilters/readability.php/test/ConfigurationTest.php b/plugins/af_readability/vendor/fivefilters/readability.php/test/ConfigurationTest.php new file mode 100644 index 000000000..b3810ed73 --- /dev/null +++ b/plugins/af_readability/vendor/fivefilters/readability.php/test/ConfigurationTest.php @@ -0,0 +1,92 @@ +<?php + +namespace andreskrey\Readability\Test; + +use andreskrey\Readability\Configuration; +use Monolog\Handler\NullHandler; +use Monolog\Logger; + +/** + * Class ConfigurationTest. + */ +class ConfigurationTest extends \PHPUnit\Framework\TestCase +{ + /** + * @dataProvider getParams + * + * @param array $params + */ + public function testConfigurationConstructorSetsParameters(array $params) + { + $config = new Configuration($params); + $this->doEqualsAsserts($config, $params); + } + + /** + * @dataProvider getParams + * + * @param array $params + */ + public function testInvalidParameterIsNotInConfig(array $params) + { + $config = new Configuration($params); + $this->assertArrayNotHasKey('invalidParameter', $config->toArray(), 'Invalid param key is not present in config'); + } + + /** + * @param Configuration $config + * @param array $options + */ + private function doEqualsAsserts(Configuration $config, array $options) + { + $this->assertEquals($options['maxTopCandidates'], $config->getMaxTopCandidates()); + $this->assertEquals($options['charThreshold'], $config->getCharThreshold()); + $this->assertEquals($options['articleByLine'], $config->getArticleByLine()); + $this->assertEquals($options['stripUnlikelyCandidates'], $config->getStripUnlikelyCandidates()); + $this->assertEquals($options['cleanConditionally'], $config->getCleanConditionally()); + $this->assertEquals($options['weightClasses'], $config->getWeightClasses()); + $this->assertEquals($options['fixRelativeURLs'], $config->getFixRelativeURLs()); + $this->assertEquals($options['substituteEntities'], $config->getSubstituteEntities()); + $this->assertEquals($options['normalizeEntities'], $config->getNormalizeEntities()); + $this->assertEquals($options['originalURL'], $config->getOriginalURL()); + $this->assertEquals($options['summonCthulhu'], $config->getOriginalURL()); + } + + /** + * @return array + */ + public function getParams() + { + return [[ + 'All current parameters' => [ + 'maxTopCandidates' => 3, + 'wordThreshold' => 500, + 'charThreshold' => 500, + 'articleByLine' => true, + 'stripUnlikelyCandidates' => false, + 'cleanConditionally' => false, + 'weightClasses' => false, + 'fixRelativeURLs' => true, + 'substituteEntities' => true, + 'normalizeEntities' => true, + 'originalURL' => 'my.original.url', + 'summonCthulhu' => 'my.original.url', + 'invalidParameter' => 'invalidParameterValue' + ] + ]]; + } + + /** + * Test if a logger interface can be injected and retrieved from the Configuration object. + */ + public function testLoggerCanBeInjected() + { + $configuration = new Configuration(); + $log = new Logger('Readability'); + $log->pushHandler(new NullHandler()); + + $configuration->setLogger($log); + + $this->assertSame($log, $configuration->getLogger()); + } +} |