PHP Classes

File: tests/NameTest.php

Recommend this page to a friend!
  Classes of Pierre-Henry Soria   Cute PHP Link Names   tests/NameTest.php   Download  
File: tests/NameTest.php
Role: Unit test script
Content type: text/plain
Description: Class source
Class: Cute PHP Link Names
Convert URL to improve its readability level
Author: By
Last change:
Date: 2 years ago
Size: 1,194 bytes
 

Contents

Class file image Download
<?php
/**
 * Pierre-Henry Soria <hi@ph7.me>
 * Copyright 2022 Pierre-Henry Soria
 * MIT License - https://opensource.org/licenses/MIT
 */

declare(strict_types=1);

namespace
PH7\Link\Tests;

use
PH7\Link\Name;
use
PHPUnit\Framework\TestCase;

final class
NameTest extends TestCase
{
   
/**
     * @dataProvider urlAndNamesProvider
     */
   
public function testLinkName(string $url, string $expectedName): void
   
{
       
$actual = Name::parse($url);
       
$this->assertSame($expectedName, $actual);
    }

    public function
urlAndNamesProvider(): array
    {
        return [
            [
               
'http://ph7.me/',
               
'Ph7'
           
],
            [
               
'http://myurl.com/path',
               
'Myurl.com Path'
           
],
            [
               
'https://pH7.me/about',
               
'Ph7.me About'
           
],
            [
               
'https://ph7.me/link-name-convertor-snippet.png',
               
'Ph7.me Link-name-convertor-snippet'
           
],
            [
               
'https://www.pierrehenry.be?myparam=value-foo-bar',
               
'Pierrehenry.be?myparam=value-foo-bar'
           
]
        ];
    }
}