PDF rausgenommen

This commit is contained in:
aschwarz
2023-01-23 11:03:31 +01:00
parent 82d562a322
commit a6523903eb
28078 changed files with 4247552 additions and 2 deletions

View File

@ -0,0 +1,77 @@
<?php
namespace Fig\Link\Tests;
use Fig\Link\GenericLinkProvider;
use Fig\Link\Link;
class GenericLinkProviderTest extends \PHPUnit_Framework_TestCase
{
public function test_can_add_links_by_method()
{
$link = (new Link())
->withHref('http://www.google.com')
->withRel('next')
->withAttribute('me', 'you')
;
$provider = (new GenericLinkProvider())
->withLink($link);
$this->assertContains($link, $provider->getLinks());
}
public function test_can_add_links_by_constructor()
{
$link = (new Link())
->withHref('http://www.google.com')
->withRel('next')
->withAttribute('me', 'you')
;
$provider = (new GenericLinkProvider())
->withLink($link);
$this->assertContains($link, $provider->getLinks());
}
public function test_can_get_links_by_rel()
{
$link1 = (new Link())
->withHref('http://www.google.com')
->withRel('next')
->withAttribute('me', 'you')
;
$link2 = (new Link())
->withHref('http://www.php-fig.org/')
->withRel('home')
->withAttribute('me', 'you')
;
$provider = (new GenericLinkProvider())
->withLink($link1)
->withLink($link2);
$links = $provider->getLinksByRel('home');
$this->assertContains($link2, $links);
$this->assertFalse(in_array($link1, $links));
}
public function test_can_remove_links()
{
$link = (new Link())
->withHref('http://www.google.com')
->withRel('next')
->withAttribute('me', 'you')
;
$provider = (new GenericLinkProvider())
->withLink($link)
->withoutLink($link);
$this->assertFalse(in_array($link, $provider->getLinks()));
}
}

View File

@ -0,0 +1,59 @@
<?php
namespace Fig\Link\Tests;
use Fig\Link\Link;
class LinkTest extends \PHPUnit_Framework_TestCase
{
public function test_can_set_and_retrieve_values()
{
$link = (new Link())
->withHref('http://www.google.com')
->withRel('next')
->withAttribute('me', 'you')
;
$this->assertEquals('http://www.google.com', $link->getHref());
$this->assertContains('next', $link->getRels());
$this->assertArrayHasKey('me', $link->getAttributes());
$this->assertEquals('you', $link->getAttributes()['me']);
}
public function test_can_remove_values()
{
$link = (new Link())
->withHref('http://www.google.com')
->withRel('next')
->withAttribute('me', 'you')
;
$link = $link->withoutAttribute('me')
->withoutRel('next');
$this->assertEquals('http://www.google.com', $link->getHref());
$this->assertFalse(in_array('next', $link->getRels()));
$this->assertFalse(array_key_exists('me', $link->getAttributes()));
}
public function test_multiple_rels()
{
$link = (new Link())
->withHref('http://www.google.com')
->withRel('next')
->withRel('reference');
$this->assertCount(2, $link->getRels());
$this->assertContains('next', $link->getRels());
$this->assertContains('reference', $link->getRels());
}
public function test_constructor()
{
$link = new Link('next', 'http://www.google.com');
$this->assertEquals('http://www.google.com', $link->getHref());
$this->assertContains('next', $link->getRels());
}
}

View File

@ -0,0 +1,56 @@
<?php
namespace Fig\Link\Tests;
use Fig\Link\Link;
class TemplatedHrefTraitTest extends \PHPUnit_Framework_TestCase {
/**
*
* @dataProvider templatedHrefProvider
*
* @param string $href
* The href to check.
*/
public function test_templated($href)
{
$link = (new Link())
->withHref($href);
$this->assertTrue($link->isTemplated());
}
/**
*
* @dataProvider notTemplatedHrefProvider
*
* @param string $href
* The href to check.
*/
public function test_not_templated($href)
{
$link = (new Link())
->withHref($href);
$this->assertFalse($link->isTemplated());
}
public function templatedHrefProvider()
{
return [
['http://www.google.com/{param}/foo'],
['http://www.google.com/foo?q={param}'],
];
}
public function notTemplatedHrefProvider()
{
return [
['http://www.google.com/foo'],
['/foo/bar/baz'],
];
}
}