withHref example

use PHPUnit\Framework\TestCase;
use Symfony\Component\WebLink\Link;

/** * Test case borrowed from https://github.com/php-fig/link/. */
class LinkTest extends TestCase
{
    public function testCanSetAndRetrieveValues()
    {
        $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 testCanRemoveValues()
    {
use Symfony\Component\WebLink\GenericLinkProvider;
use Symfony\Component\WebLink\Link;

/** * Test case borrowed from https://github.com/php-fig/link/. */
class GenericLinkProviderTest extends TestCase
{
    public function testCanAddLinksByMethod()
    {
        $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 testCanAddLinksByConstructor()
    {
Home | Imprint | This part of the site doesn't use cookies.