PHP Classes

File: tests/UrlFilterTest.php

Recommend this page to a friend!
  Classes of Igor Dyshlenko   PHP Image Crawler   tests/UrlFilterTest.php   Download  
File: tests/UrlFilterTest.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: 949 bytes
 

Contents

Class file image Download
<?php

use PHPUnit\Framework\TestCase;
use
App\UrlFilter;

class
UrlFilterTest extends TestCase
{
    public function
testEmptyList(): void
   
{
       
$content = '<body><html><div></div></html></body>';
       
$this->assertEquals([], UrlFilter::getInstance()->handle($content));
    }

    public function
testFewUrls(): void
   
{
       
$content = '<html>
  <body>
    <a href="http://www.example.com">Example</a>
    <div>
        <a href="http://www.stackoverflow.com/users/345120">SO</a>
    </div>
    <a href="www.stackoverflow.com/users/345120">SO</a>
    <a href="/users/345120">SO</a>
  </body>
</html>'
;

       
$this->assertEquals(['http://www.example.com',
                            
'http://www.stackoverflow.com/users/345120',
                            
'www.stackoverflow.com/users/345120',
                            
'/users/345120'],
                           
UrlFilter::getInstance()->handle($content));
    }
}