Fix deprecated method in tests

This commit is contained in:
Jeremy Benoist
2020-06-15 13:37:50 +02:00
parent 7332d1f4e5
commit 732ec8a2eb
44 changed files with 314 additions and 326 deletions

View File

@ -176,7 +176,7 @@ class ContentProxyTest extends TestCase
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('content', $entry->getContent());
$this->assertStringContainsString('content', $entry->getContent());
$this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
@ -221,7 +221,7 @@ class ContentProxyTest extends TestCase
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('content', $entry->getContent());
$this->assertStringContainsString('content', $entry->getContent());
$this->assertNull($entry->getPreviewPicture());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
@ -357,7 +357,7 @@ class ContentProxyTest extends TestCase
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('content', $entry->getContent());
$this->assertStringContainsString('content', $entry->getContent());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertNull($entry->getLanguage());
$this->assertSame('200', $entry->getHttpStatus());
@ -409,7 +409,7 @@ class ContentProxyTest extends TestCase
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('content', $entry->getContent());
$this->assertStringContainsString('content', $entry->getContent());
$this->assertNull($entry->getPreviewPicture());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
@ -449,7 +449,7 @@ class ContentProxyTest extends TestCase
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('content', $entry->getContent());
$this->assertStringContainsString('content', $entry->getContent());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame(4.0, $entry->getReadingTime());
@ -492,7 +492,7 @@ class ContentProxyTest extends TestCase
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('content', $entry->getContent());
$this->assertStringContainsString('content', $entry->getContent());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame(4.0, $entry->getReadingTime());
@ -531,7 +531,7 @@ class ContentProxyTest extends TestCase
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('content', $entry->getContent());
$this->assertStringContainsString('content', $entry->getContent());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
$this->assertSame(4.0, $entry->getReadingTime());
@ -541,7 +541,7 @@ class ContentProxyTest extends TestCase
$records = $handler->getRecords();
$this->assertCount(3, $records);
$this->assertContains('Error while defining date', $records[0]['message']);
$this->assertStringContainsString('Error while defining date', $records[0]['message']);
}
public function testTaggerThrowException()
@ -619,7 +619,7 @@ class ContentProxyTest extends TestCase
$this->assertSame('http://1.1.1.1', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertNotContains($escapedString, $entry->getContent());
$this->assertStringNotContainsString($escapedString, $entry->getContent());
$this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
$this->assertSame('text/html', $entry->getMimetype());
$this->assertSame('fr', $entry->getLanguage());
@ -658,7 +658,7 @@ class ContentProxyTest extends TestCase
$this->assertSame('http://1.1.1.1/image.jpg', $entry->getUrl());
$this->assertSame('this is my title', $entry->getTitle());
$this->assertContains('http://1.1.1.1/image.jpg', $entry->getContent());
$this->assertStringContainsString('http://1.1.1.1/image.jpg', $entry->getContent());
$this->assertSame('http://1.1.1.1/image.jpg', $entry->getPreviewPicture());
$this->assertSame('image/jpeg', $entry->getMimetype());
$this->assertSame('200', $entry->getHttpStatus());

View File

@ -23,18 +23,15 @@ class CryptoProxyTest extends TestCase
$records = $logHandler->getRecords();
$this->assertCount(2, $records);
$this->assertContains('Crypto: crypting value', $records[0]['message']);
$this->assertContains('Crypto: decrypting value', $records[1]['message']);
$this->assertStringContainsString('Crypto: crypting value', $records[0]['message']);
$this->assertStringContainsString('Crypto: decrypting value', $records[1]['message']);
}
/**
* @expectedException \RuntimeException
* @expectedExceptionMessage Decrypt fail
*
* @return [type] [description]
*/
public function testDecryptBadValue()
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('Decrypt fail');
$crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', new NullLogger());
$crypto->decrypt('badvalue');
}

View File

@ -42,7 +42,7 @@ class DownloadImagesTest extends TestCase
$res = $download->processHtml(123, $html, $url);
// this the base path of all image (since it's calculated using the entry id: 123)
$this->assertContains('http://wallabag.io/assets/images/9/b/9b0ead26/', $res);
$this->assertStringContainsString('http://wallabag.io/assets/images/9/b/9b0ead26/', $res);
}
public function testProcessHtmlWithBadImage()
@ -56,7 +56,7 @@ class DownloadImagesTest extends TestCase
$download = new DownloadImages($httpMockClient, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY');
$this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type');
$this->assertStringContainsString('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type');
}
public function singleImage()
@ -83,7 +83,7 @@ class DownloadImagesTest extends TestCase
$download = new DownloadImages($httpMockClient, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
$this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.' . $extension, $res);
$this->assertStringContainsString('/assets/images/9/b/9b0ead26/ebe60399.' . $extension, $res);
}
public function testProcessSingleImageWithBadUrl()
@ -144,8 +144,8 @@ class DownloadImagesTest extends TestCase
'https://theconversation.com/conversation-avec-gerald-bronner-ce-nest-pas-la-post-verite-qui-nous-menace-mais-lextension-de-notre-credulite-73089'
);
$this->assertContains('http://wallabag.io/assets/images/9/b/9b0ead26/', $res, 'Content-Type was empty but data is ok for an image');
$this->assertContains('DownloadImages: Checking extension (alternative)', $logHandler->getRecords()[3]['message']);
$this->assertStringContainsString('http://wallabag.io/assets/images/9/b/9b0ead26/', $res, 'Content-Type was empty but data is ok for an image');
$this->assertStringContainsString('DownloadImages: Checking extension (alternative)', $logHandler->getRecords()[3]['message']);
}
public function testProcessImageWithSrcset()
@ -161,7 +161,7 @@ class DownloadImagesTest extends TestCase
$download = new DownloadImages($httpMockClient, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
$res = $download->processHtml(123, '<p><img class="alignnone wp-image-1153" src="http://piketty.blog.lemonde.fr/files/2017/10/F1FR-530x375.jpg" alt="" width="628" height="444" srcset="http://piketty.blog.lemonde.fr/files/2017/10/F1FR-530x375.jpg 530w, http://piketty.blog.lemonde.fr/files/2017/10/F1FR-768x543.jpg 768w, http://piketty.blog.lemonde.fr/files/2017/10/F1FR-900x636.jpg 900w" sizes="(max-width: 628px) 100vw, 628px" /></p>', 'http://piketty.blog.lemonde.fr/2017/10/12/budget-2018-la-jeunesse-sacrifiee/');
$this->assertNotContains('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced');
$this->assertStringNotContainsString('http://piketty.blog.lemonde.fr/', $res, 'Image srcset attribute were not replaced');
}
public function testProcessImageWithTrickySrcset()
@ -181,7 +181,7 @@ class DownloadImagesTest extends TestCase
(min-width: 626px) calc(100vw - 335px)
calc(100vw - 30px)" alt="" /></figure>', 'https://css-tricks.com/the-critical-request/');
$this->assertNotContains('f_auto,q_auto', $res, 'Image srcset attribute were not replaced');
$this->assertStringNotContainsString('f_auto,q_auto', $res, 'Image srcset attribute were not replaced');
}
public function testProcessImageWithNullPath()