diff --git a/.travis.yml b/.travis.yml index 8680bd4..c3c95c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,11 @@ language: php -sudo: required -dist: trusty -group: edge php: - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - hhvm-3.9 - - hhvm-3.18 + - 7.3 + - 7.4 + - 8.0 before_script: - composer install -script: ./vendor/bin/phpunit --coverage-text +script: XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-text diff --git a/composer.json b/composer.json index b0dfe14..dc3d1ca 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "php": ">=5.6.0" + "php": ">=7.3.0" }, "autoload": { "psr-4": { "EmailReplyParser\\": "src/EmailReplyParser" } @@ -25,6 +25,6 @@ } }, "require-dev": { - "phpunit/phpunit": "^4.8.35|^5.7" + "phpunit/phpunit": "^9.5" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d191896..8bdd248 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,23 +1,13 @@ - - - - ./tests/ - - - - - ./src/EmailReplyParser/ - - + + + + ./src/EmailReplyParser/ + + + + + ./tests/ + + diff --git a/tests/EmailReplyParser/Tests/Parser/EmailParserTest.php b/tests/EmailReplyParser/Tests/Parser/EmailParserTest.php index d5bdf37..d9f2070 100644 --- a/tests/EmailReplyParser/Tests/Parser/EmailParserTest.php +++ b/tests/EmailReplyParser/Tests/Parser/EmailParserTest.php @@ -18,7 +18,7 @@ class EmailParserTest extends TestCase */ private $parser; - protected function setUp() + protected function setUp(): void { $this->parser = new EmailParser(); } @@ -89,10 +89,10 @@ public function testReadsTopPost() $this->assertTrue($fragments[3]->isHidden()); $this->assertTrue($fragments[4]->isHidden()); - $this->assertRegExp('/^Oh thanks.\n\nHaving/', (string) $fragments[0]); - $this->assertRegExp('/^-A/', (string) $fragments[1]); - $this->assertRegExp('/^On [^\:]+\:/', (string) $fragments[2]); - $this->assertRegExp('/^_/', (string) $fragments[4]); + $this->assertMatchesRegularExpression('/^Oh thanks.\n\nHaving/', (string) $fragments[0]); + $this->assertMatchesRegularExpression('/^-A/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^On [^\:]+\:/', (string) $fragments[2]); + $this->assertMatchesRegularExpression('/^_/', (string) $fragments[4]); } public function testReadsBottomPost() @@ -102,10 +102,10 @@ public function testReadsBottomPost() $this->assertCount(6, $fragments); $this->assertEquals('Hi,', (string) $fragments[0]); - $this->assertRegExp('/^On [^\:]+\:/', (string) $fragments[1]); - $this->assertRegExp('/^You can list/', (string) $fragments[2]); - $this->assertRegExp('/^>/', (string) $fragments[3]); - $this->assertRegExp('/^_/', (string) $fragments[5]); + $this->assertMatchesRegularExpression('/^On [^\:]+\:/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^You can list/', (string) $fragments[2]); + $this->assertMatchesRegularExpression('/^>/', (string) $fragments[3]); + $this->assertMatchesRegularExpression('/^_/', (string) $fragments[5]); } public function testRecognizesDateStringAboveQuote() @@ -113,9 +113,9 @@ public function testRecognizesDateStringAboveQuote() $email = $this->parser->parse($this->getFixtures('email_4.txt')); $fragments = $email->getFragments(); - $this->assertRegExp('/^Awesome/', (string) $fragments[0]); - $this->assertRegExp('/^On/', (string) $fragments[1]); - $this->assertRegExp('/Loader/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^Awesome/', (string) $fragments[0]); + $this->assertMatchesRegularExpression('/^On/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/Loader/', (string) $fragments[1]); } public function testDoesNotModifyInputString() @@ -138,9 +138,9 @@ public function testDealsWithMultilineReplyHeaders() $email = $this->parser->parse($this->getFixtures('email_6.txt')); $fragments = $email->getFragments(); - $this->assertRegExp('/^I get/', (string) $fragments[0]); - $this->assertRegExp('/^On/', (string) $fragments[1]); - $this->assertRegExp('/Was this/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^I get/', (string) $fragments[0]); + $this->assertMatchesRegularExpression('/^On/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/Was this/', (string) $fragments[1]); } public function testEmailItalian() @@ -289,7 +289,7 @@ public function testReadsEmailWithCorrectSignature() $this->assertFalse($fragments[0]->isHidden()); $this->assertTrue($fragments[1]->isHidden()); - $this->assertRegExp('/^--\nrick/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^--\nrick/', (string) $fragments[1]); } public function testReadsEmailWithSignatureWithNoEmptyLineAbove() @@ -308,7 +308,7 @@ public function testReadsEmailWithSignatureWithNoEmptyLineAbove() $this->assertFalse($fragments[0]->isHidden()); $this->assertTrue($fragments[1]->isHidden()); - $this->assertRegExp('/^--\nrick/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^--\nrick/', (string) $fragments[1]); } public function testReadsEmailWithCorrectSignatureWithSpace() @@ -330,7 +330,7 @@ public function testReadsEmailWithCorrectSignatureWithSpace() $this->assertFalse($fragments[0]->isHidden()); $this->assertTrue($fragments[1]->isHidden()); - $this->assertRegExp('/^-- \nrick/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^-- \nrick/', (string) $fragments[1]); } public function testReadsEmailWithCorrectSignatureWithNoEmptyLineWithSpace() @@ -352,7 +352,7 @@ public function testReadsEmailWithCorrectSignatureWithNoEmptyLineWithSpace() $this->assertFalse($fragments[0]->isHidden()); $this->assertTrue($fragments[1]->isHidden()); - $this->assertRegExp('/^-- \nrick/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^-- \nrick/', (string) $fragments[1]); } public function testOneIsNotOn() @@ -360,8 +360,8 @@ public function testOneIsNotOn() $email = $this->parser->parse($this->getFixtures('email_one_is_not_on.txt')); $fragments = $email->getFragments(); - $this->assertRegExp('/One outstanding question/', (string) $fragments[0]); - $this->assertRegExp('/^On Oct 1, 2012/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/One outstanding question/', (string) $fragments[0]); + $this->assertMatchesRegularExpression('/^On Oct 1, 2012/', (string) $fragments[1]); } public function testCustomQuoteHeader() @@ -411,25 +411,25 @@ public function testVisibleTextSeemsLikeAQuoteHeader1() { $email = $this->parser->parse($this->getFixtures('email_19.txt')); $fragments = $email->getFragments(); - $this->assertRegexp('/^On Thursday/', (string) $fragments[0]); - $this->assertRegexp('/^On Dec 16/', (string) $fragments[1]); - $this->assertRegExp('/Was this/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^On Thursday/', (string) $fragments[0]); + $this->assertMatchesRegularExpression('/^On Dec 16/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/Was this/', (string) $fragments[1]); } public function testVisibleTextSeemsLikeAQuoteHeader2() { $email = $this->parser->parse($this->getFixtures('email_20.txt')); $fragments = $email->getFragments(); - $this->assertRegexp('/^On Thursday/', (string) $fragments[0]); - $this->assertRegexp('/^> On May 17/', (string) $fragments[1]); - $this->assertRegExp('/fix this parsing/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/^On Thursday/', (string) $fragments[0]); + $this->assertMatchesRegularExpression('/^> On May 17/', (string) $fragments[1]); + $this->assertMatchesRegularExpression('/fix this parsing/', (string) $fragments[1]); } public function testEmailWithFairAmountOfContent() { $email = $this->parser->parse($this->getFixtures('email_21.txt')); $fragments = $email->getFragments(); - $this->assertRegexp('/^On Thursday/', (string) $fragments[0]); + $this->assertMatchesRegularExpression('/^On Thursday/', (string) $fragments[0]); } /** diff --git a/tests/Fixtures/email_issue_77.txt b/tests/Fixtures/email_issue_77.txt new file mode 100644 index 0000000..97f4d36 --- /dev/null +++ b/tests/Fixtures/email_issue_77.txt @@ -0,0 +1,11 @@ +Bonjour Test, + + Text paragraph 1 + + +Le paragraphe qui pose problème. + + Text paragraph 2 + + +- Le 2021-04-09 23:25, Test a écrit :