diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml
index 2c23bd4..cd666ae 100644
--- a/.github/workflows/coding-standards.yml
+++ b/.github/workflows/coding-standards.yml
@@ -14,7 +14,7 @@ env:
jobs:
coding-standards:
name: "CS Fixer & PHPStan"
- runs-on: "ubuntu-18.04"
+ runs-on: "ubuntu-20.04"
strategy:
matrix:
diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml
index 42b2d41..1424248 100644
--- a/.github/workflows/continuous-integration.yml
+++ b/.github/workflows/continuous-integration.yml
@@ -14,7 +14,7 @@ env:
jobs:
phpunit:
name: "PHPUnit (PHP ${{ matrix.php }})"
- runs-on: "ubuntu-18.04"
+ runs-on: "ubuntu-20.04"
strategy:
matrix:
@@ -25,6 +25,7 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
+ - "8.0"
steps:
- name: "Checkout"
@@ -65,7 +66,7 @@ jobs:
phpunit-coverage:
name: "PHPUnit coverage (PHP ${{ matrix.php }})"
- runs-on: "ubuntu-18.04"
+ runs-on: "ubuntu-20.04"
strategy:
matrix:
@@ -118,7 +119,7 @@ jobs:
phpunit-lowest:
name: "PHPUnit lowest deps (PHP ${{ matrix.php }})"
- runs-on: "ubuntu-18.04"
+ runs-on: "ubuntu-20.04"
strategy:
matrix:
@@ -161,7 +162,7 @@ jobs:
phpunit-composerv2:
name: "PHPUnit with Composer v2 (PHP ${{ matrix.php }})"
- runs-on: "ubuntu-18.04"
+ runs-on: "ubuntu-20.04"
strategy:
matrix:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 2ed6a99..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,34 +0,0 @@
-dist: xenial
-os: linux
-language: php
-
-# avoid double Travis build when the PR is created on upstream
-if: |
- type = pull_request OR \
- branch = master
-
-jobs:
- include:
- - php: 8.0
- env: SYMFONY_PHPUNIT_VERSION=7.5
- fast_finish: true
- allow_failures:
- - php: 8.0
-
-cache:
- directories:
- - $HOME/.composer/cache/files
-
-before_install:
- - if [ -n "$GH_TOKEN" ]; then composer config github-oauth.github.com ${GH_TOKEN}; fi;
-
-install:
- - if [ "$CS_FIXER" != "run" ]; then composer remove friendsofphp/php-cs-fixer --dev --no-progress --no-update ; fi;
- - composer update --prefer-dist --no-progress -o
- - php vendor/bin/simple-phpunit install
-
-before_script:
- - mkdir -p build/logs
-
-script:
- - php vendor/bin/simple-phpunit -v
diff --git a/README.md b/README.md
index a1eebee..e3f3cf7 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,6 @@
# Readability
![CI](https://github.com/j0k3r/php-readability/workflows/CI/badge.svg)
-[![Build Status](https://travis-ci.org/j0k3r/php-readability.svg?branch=master)](https://travis-ci.org/j0k3r/php-readability)
[![Coverage Status](https://coveralls.io/repos/j0k3r/php-readability/badge.svg?branch=master&service=github)](https://coveralls.io/github/j0k3r/php-readability/?branch=master)
[![Total Downloads](https://poser.pugx.org/j0k3r/php-readability/downloads)](https://packagist.org/packages/j0k3r/php-readability)
[![License](https://poser.pugx.org/j0k3r/php-readability/license)](https://packagist.org/packages/j0k3r/php-readability)
diff --git a/src/Readability.php b/src/Readability.php
index 1ed93ea..db2e27a 100644
--- a/src/Readability.php
+++ b/src/Readability.php
@@ -187,6 +187,9 @@ public function __construct($html, $url = null, $parser = 'libxml', $use_tidy =
$this->loadHtml();
}
+ /**
+ * @return void
+ */
public function setLogger(LoggerInterface $logger)
{
$this->logger = $logger;
diff --git a/tests/ReadabilityTest.php b/tests/ReadabilityTest.php
index e345947..dfe3cf6 100644
--- a/tests/ReadabilityTest.php
+++ b/tests/ReadabilityTest.php
@@ -74,7 +74,7 @@ public function testInitNoContent()
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
$this->assertEmpty($readability->getTitle()->getInnerHtml());
- $this->assertContains('Sorry, Readability was unable to parse this page for content.', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('Sorry, Readability was unable to parse this page for content.', $readability->getContent()->getInnerHtml());
}
public function testInitP()
@@ -85,9 +85,9 @@ public function testInitP()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('
getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is the awesome content :)', $readability->getContent()->getInnerHtml());
}
public function testInitDivP()
@@ -98,9 +98,9 @@ public function testInitDivP()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('
getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is the awesome content :)', $readability->getContent()->getInnerHtml());
}
public function testInitDiv()
@@ -112,9 +112,9 @@ public function testInitDiv()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('
getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is the awesome content :)', $readability->getContent()->getInnerHtml());
}
public function testWithFootnotes()
@@ -127,11 +127,11 @@ public function testWithFootnotes()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('
getContent()->getInnerHtml());
- $this->assertContains('readabilityFootnoteLink', $readability->getContent()->getInnerHtml());
- $this->assertContains('readabilityLink-3', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('readabilityFootnoteLink', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('readabilityLink-3', $readability->getContent()->getInnerHtml());
}
public function testStandardClean()
@@ -144,11 +144,11 @@ public function testStandardClean()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('
getContent()->getInnerHtml());
- $this->assertContains('will NOT be removed', $readability->getContent()->getInnerHtml());
- $this->assertNotContains('
', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('will NOT be removed', $readability->getContent()->getInnerHtml());
+ $this->assertStringNotContainsString('', $readability->getContent()->getInnerHtml());
}
public function testWithIframe()
@@ -160,10 +160,10 @@ public function testWithIframe()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('getContent()->getInnerHtml());
- $this->assertContains('nofollow', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('nofollow', $readability->getContent()->getInnerHtml());
}
public function testWithArticle()
@@ -175,10 +175,10 @@ public function testWithArticle()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('alt="article"', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('alt="article"', $readability->getContent()->getInnerHtml());
$this->assertEmpty($readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertContains('nofollow', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('nofollow', $readability->getContent()->getInnerHtml());
}
public function testWithAside()
@@ -191,9 +191,9 @@ public function testWithAside()
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
$this->assertEmpty($readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertNotContains('
', $readability->getContent()->getInnerHtml());
- $this->assertContains('', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringNotContainsString('', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('', $readability->getContent()->getInnerHtml());
}
public function testWithClasses()
@@ -205,10 +205,10 @@ public function testWithClasses()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('alt="article"', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('alt="article"', $readability->getContent()->getInnerHtml());
$this->assertEmpty($readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertNotContains('This text should be removed', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringNotContainsString('This text should be removed', $readability->getContent()->getInnerHtml());
}
public function testWithClassesWithoutLightClean()
@@ -221,10 +221,10 @@ public function testWithClassesWithoutLightClean()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('alt="article"', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('alt="article"', $readability->getContent()->getInnerHtml());
$this->assertEmpty($readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertNotContains('This text should be removed', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringNotContainsString('This text should be removed', $readability->getContent()->getInnerHtml());
}
public function testWithTd()
@@ -237,7 +237,7 @@ public function testWithTd()
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
$this->assertEmpty($readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
}
public function testWithSameClasses()
@@ -250,8 +250,8 @@ public function testWithSameClasses()
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
$this->assertEmpty($readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertContains('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
}
public function testWithScript()
@@ -264,8 +264,8 @@ public function testWithScript()
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
$this->assertEmpty($readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertNotContains('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringNotContainsString('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
}
public function testTitle()
@@ -278,8 +278,8 @@ public function testTitle()
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
$this->assertEquals('this is my title', $readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertNotContains('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringNotContainsString('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
}
public function testTitleWithDash()
@@ -292,8 +292,8 @@ public function testTitleWithDash()
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
$this->assertEquals('title2 - title3', $readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertNotContains('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringNotContainsString('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
}
public function testTitleWithDoubleDot()
@@ -306,8 +306,8 @@ public function testTitleWithDoubleDot()
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
$this->assertEquals('title2 : title3', $readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertNotContains('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringNotContainsString('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
}
public function testTitleTooShortUseH1()
@@ -320,8 +320,8 @@ public function testTitleTooShortUseH1()
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
$this->assertEquals('this is my h1 title !', $readability->getTitle()->getInnerHtml());
- $this->assertContains('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
- $this->assertNotContains('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This is an awesome text with some links, here there are', $readability->getContent()->getInnerHtml());
+ $this->assertStringNotContainsString('This text is also an awesome text and you should know that', $readability->getContent()->getInnerHtml());
}
// dummy function to be used to the next test
@@ -369,8 +369,8 @@ public function testAutoClosingIframeNotThrowingException()
$this->assertTrue($res);
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getContent());
$this->assertInstanceOf('Readability\JSLikeHTMLElement', $readability->getTitle());
- $this->assertContains('VIDEO ', $readability->getContent()->getInnerHtml());
- $this->assertContains('3D Touch', $readability->getTitle()->getInnerHtml());
+ $this->assertStringContainsString('VIDEO ', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('3D Touch', $readability->getTitle()->getInnerHtml());
}
/**
@@ -440,7 +440,7 @@ public function testPostFilters()
$res = $readability->init();
$this->assertTrue($res);
- $this->assertContains('This the awesome content :)', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This the awesome content :)', $readability->getContent()->getInnerHtml());
}
public function testPreFilters()
@@ -453,7 +453,7 @@ public function testPreFilters()
$res = $readability->init();
$this->assertTrue($res);
- $this->assertContains('This the awesome and WONDERFUL content :)', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('This the awesome and WONDERFUL content :)', $readability->getContent()->getInnerHtml());
}
public function testChildNodeGoneNull()
@@ -479,8 +479,8 @@ public function testKeepFootnotes()
$res = $readability->init();
$this->assertTrue($res);
- $this->assertContains(' ', $readability->getContent()->getInnerHtml());
- $this->assertContains('getContent()->getInnerHtml());
+ $this->assertStringContainsString(' ', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString(' getContent()->getInnerHtml());
}
public function testWithWipedBody()
@@ -493,7 +493,7 @@ public function testWithWipedBody()
$res = $readability->init();
$this->assertTrue($res);
- $this->assertContains(' Down the Rabbit-Hole ', $readability->getContent()->getInnerHtml());
+ $this->assertStringContainsString('Down the Rabbit-Hole ', $readability->getContent()->getInnerHtml());
}
private function getReadability($html, $url = null, $parser = 'libxml', $useTidy = true)