-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
/** | ||
* Atom Protocol support | ||
* | ||
* @author Михаил Красильников <m.krasilnikov@yandex.ru> | ||
* @license MIT | ||
*/ | ||
namespace Mekras\Atom\Tests\Element; | ||
|
||
use Mekras\Atom\Element\Title; | ||
use Mekras\Atom\Tests\TestCase; | ||
|
||
/** | ||
* Tests for Mekras\Atom\Element\Content | ||
*/ | ||
class TitleTest extends TestCase | ||
{ | ||
/** | ||
* Test "text" type | ||
*/ | ||
public function testText() | ||
{ | ||
$doc = $this->createDocument('Less: <'); | ||
$title = new Title($this->createFakeNode(), $doc->documentElement); | ||
static::assertEquals('text', $title->getType()); | ||
static::assertEquals('Less: <', (string) $title); | ||
} | ||
|
||
/** | ||
* Test "html" type | ||
*/ | ||
public function testHtml() | ||
{ | ||
$doc = $this->createDocument('<title type="html"><em> &lt; </em></title>'); | ||
|
||
$title = new Title($this->createFakeNode(), $doc->documentElement->firstChild); | ||
static::assertEquals('html', $title->getType()); | ||
static::assertEquals('<em> < </em>', (string) $title); | ||
} | ||
|
||
/** | ||
* Test "xhtml" type | ||
*/ | ||
public function testXhtml() | ||
{ | ||
$doc = $this->createDocument( | ||
'<title type="xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml">' . | ||
'<xhtml:div><xhtml:em> < </xhtml:em></xhtml:div>' . | ||
'</title>' | ||
); | ||
|
||
$title = new Title($this->createFakeNode(), $doc->documentElement->firstChild); | ||
static::assertEquals('xhtml', $title->getType()); | ||
static::assertEquals('<em> < </em>', (string) $title); | ||
} | ||
|
||
/** | ||
* __toString should return an empty string in case of error. | ||
*/ | ||
public function testRenderError() | ||
{ | ||
$doc = $this->createDocument( | ||
'<title type="xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml"></title>' | ||
); | ||
|
||
$title = new Title($this->createFakeNode(), $doc->documentElement->firstChild); | ||
static::assertEquals('', (string) $title); | ||
} | ||
|
||
/** | ||
* Test set/get | ||
*/ | ||
public function testSetGet() | ||
{ | ||
$doc = $this->createDocument('foo'); | ||
$title = new Title($this->createFakeNode(), $doc->documentElement); | ||
static::assertEquals('foo', (string) $title); | ||
$title->setValue('bar'); | ||
static::assertEquals('bar', (string) $title); | ||
} | ||
} |