![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/dceprojects.corals.io/node_modules/@nesk/puphpeteer/tests/ |
<?php namespace Nesk\Puphpeteer\Tests; use Nesk\Puphpeteer\Puppeteer; use Nesk\Rialto\Data\JsFunction; use PHPUnit\Framework\ExpectationFailedException; use Nesk\Puphpeteer\Resources\ElementHandle; class DownloadTest extends TestCase { public function setUp(): void { parent::setUp(); // Serve the content of the "/resources"-folder to test these. $this->serveResources(); // Launch the browser to run tests on. $this->launchBrowser(); } /** * Downloads an image and checks string length. * * @test */ public function download_image() { // Download the image $page = $this->browser ->newPage() ->goto($this->url . '/puphpeteer-logo.png'); $base64 = $page->buffer()->toString('base64'); $imageString = base64_decode($base64); // Get the reference image from resources $reference = file_get_contents('tests/resources/puphpeteer-logo.png'); $this->assertTrue( mb_strlen($reference) === mb_strlen($imageString), 'Image is not the same length after download.' ); } /** * Downloads an image and checks string length. * * @test */ // public function download_large_image() // { // // Download the image // $page = $this->browser // ->newPage() // ->goto($this->url . '/denys-barabanov-jKcFmXCfaQ8-unsplash.jpg'); // $base64 = $page->buffer()->toString('base64'); // $imageString = base64_decode($base64); // // Get the reference image from resources // $reference = file_get_contents('tests/resources/denys-barabanov-jKcFmXCfaQ8-unsplash.jpg'); // $this->assertTrue( // mb_strlen($reference) === mb_strlen($imageString), // 'Large image is not the same length after download.' // ); // } }