Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add setUrl() method (fixes #227) #244

Merged
merged 1 commit into from
May 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Inline/Element/AbstractWebResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,16 @@ public function getUrl()
{
return $this->url;
}

/**
* @param string $url
*
* @return $this
*/
public function setUrl($url)
{
$this->url = $url;

return $this;
}
}
41 changes: 41 additions & 0 deletions tests/unit/Inline/Element/AbstractWebResourceTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

namespace League\CommonMark\Tests\Unit\Inline\Element;

use League\CommonMark\Inline\Element\AbstractWebResource;

class AbstractWebResourceTest extends \PHPUnit_Framework_TestCase
{
/**
* Tests the URL constructor parameter and getUrl() method
*/
public function testConstructorAndGetUrl()
{
$url = 'https://www.example.com/foo';

/** @var AbstractWebResource $element */
$element = $this->getMockBuilder('League\\CommonMark\\Inline\\Element\\AbstractWebResource')
->setConstructorArgs([$url])
->getMockForAbstractClass();

$this->assertEquals($url, $element->getUrl());
}

/**
* Tests the setUrl() method
*/
public function testSetUrl()
{
$url1 = 'https://www.example.com/foo';
$url2 = 'https://www.example.com/bar';

/** @var AbstractWebResource $element */
$element = $this->getMockBuilder('League\\CommonMark\\Inline\\Element\\AbstractWebResource')
->setConstructorArgs([$url1])
->getMockForAbstractClass();

$element->setUrl($url2);

$this->assertEquals($url2, $element->getUrl());
}
}