PHP Classes

File: tests/ContentLoaderTest.php

Recommend this page to a friend!
  Classes of Igor Dyshlenko   PHP Image Crawler   tests/ContentLoaderTest.php   Download  
File: tests/ContentLoaderTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: PHP Image Crawler
Crawl Web site pages to find images in the pages
Author: By
Last change:
Date: 4 years ago
Size: 1,226 bytes
 

Contents

Class file image Download
<?php

use PHPUnit\Framework\TestCase;
use
App\ContentLoader;

class
ContentLoaderTest extends TestCase
{
    public function
testLoadEmptyList(): void
   
{
       
$loader = ContentLoader::getInstance();
       
$content = $loader->loadContent([]);
       
$this->assertEquals([], $content);
    }

    public function
testLoadOneUrl(): void
   
{
       
$url = 'http://example.com/';
       
$loader = ContentLoader::getInstance();
       
$content = $loader->loadContent([$url]);
       
$this->assertCount(1, $content);
       
$this->assertArrayHasKey($url, $content);
       
$this->assertNotEmpty($content[$url]);
    }

    public function
testLoadFewUrl(): void
   
{
       
$urls = ['http://example.com/',
                
'http://www.example.com/',
                
'http://example.org/',
                
'http://www.example.org/'];

       
$loader = ContentLoader::getInstance();
       
$content = $loader->loadContent($urls);
       
$this->assertCount(count($urls), $content);
        foreach (
$urls as $url) {
           
$this->assertArrayHasKey($url, $content);
           
$this->assertInternalType('string', $content[$url]);
           
$this->assertNotEmpty($content[$url]);
        }
    }
}