@@ -13,8 +13,8 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * Test that links are included in the content field |
| 15 | 15 | */ |
| 16 | - public function testInsertion(){ |
|
| 17 | - $this->objFromFixture('AutomatedLink','link'); |
|
| 16 | + public function testInsertion() { |
|
| 17 | + $this->objFromFixture('AutomatedLink', 'link'); |
|
| 18 | 18 | $page = $this->createPage('<p>Checking if phrase is replaced</p>'); |
| 19 | 19 | $link = $this->getLinkFromPage($page); |
| 20 | 20 | $this->assertTrue($link->nodeValue === 'phrase', 'Link wasn\'t created'); |
@@ -23,42 +23,42 @@ discard block |
||
| 23 | 23 | /** |
| 24 | 24 | * Test the individual properties of the automated link |
| 25 | 25 | */ |
| 26 | - public function testProperties(){ |
|
| 27 | - $this->objFromFixture('AutomatedLink','link2'); |
|
| 26 | + public function testProperties() { |
|
| 27 | + $this->objFromFixture('AutomatedLink', 'link2'); |
|
| 28 | 28 | |
| 29 | 29 | $page = $this->createPage('<p>Checking if properties is with correct props</p>'); |
| 30 | 30 | $link = $this->getLinkFromPage($page); |
| 31 | 31 | |
| 32 | - $this->assertTrue( $link->nodeValue === 'properties', 'Phrase did not match' ); |
|
| 33 | - $this->assertTrue( $link->getAttribute('title') === 'test title', 'Title did not match' ); |
|
| 34 | - $this->assertTrue( $link->getAttribute('href') === '#test-anchor', 'Anchor did not match' ); |
|
| 35 | - $this->assertTrue( $link->getAttribute('target') === '_blank', 'Target did not match' ); |
|
| 36 | - $this->assertTrue( $link->getAttribute('rel') === 'nofollow', 'Rel did not match' ); |
|
| 32 | + $this->assertTrue($link->nodeValue === 'properties', 'Phrase did not match'); |
|
| 33 | + $this->assertTrue($link->getAttribute('title') === 'test title', 'Title did not match'); |
|
| 34 | + $this->assertTrue($link->getAttribute('href') === '#test-anchor', 'Anchor did not match'); |
|
| 35 | + $this->assertTrue($link->getAttribute('target') === '_blank', 'Target did not match'); |
|
| 36 | + $this->assertTrue($link->getAttribute('rel') === 'nofollow', 'Rel did not match'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Test that the default properties match what we expect |
| 41 | 41 | */ |
| 42 | - public function testDefaultProperties(){ |
|
| 43 | - $this->objFromFixture('AutomatedLink','link3'); |
|
| 42 | + public function testDefaultProperties() { |
|
| 43 | + $this->objFromFixture('AutomatedLink', 'link3'); |
|
| 44 | 44 | |
| 45 | 45 | $page = $this->createPage('<p>Checking if default is correct</p>'); |
| 46 | 46 | $link = $this->getLinkFromPage($page); |
| 47 | 47 | $auto = AutomatedLink::get()->find('Phrase', 'default'); |
| 48 | 48 | |
| 49 | - $this->assertTrue( $link->nodeValue === 'default', 'Phrase did not match' ); |
|
| 50 | - $this->assertTrue( $link->getAttribute('title') === '', 'Title did not match' ); |
|
| 51 | - $this->assertTrue( $link->getAttribute('href') === '#', 'href did not match' ); |
|
| 52 | - $this->assertTrue( $link->getAttribute('target') === '', 'Target did not match' ); |
|
| 53 | - $this->assertTrue( $link->getAttribute('rel') === '', 'Rel did not match' ); |
|
| 54 | - $this->assertTrue( (int) $link->getAttribute('data-id') === $auto->ID, 'data-id did not match' ); |
|
| 49 | + $this->assertTrue($link->nodeValue === 'default', 'Phrase did not match'); |
|
| 50 | + $this->assertTrue($link->getAttribute('title') === '', 'Title did not match'); |
|
| 51 | + $this->assertTrue($link->getAttribute('href') === '#', 'href did not match'); |
|
| 52 | + $this->assertTrue($link->getAttribute('target') === '', 'Target did not match'); |
|
| 53 | + $this->assertTrue($link->getAttribute('rel') === '', 'Rel did not match'); |
|
| 54 | + $this->assertTrue((int) $link->getAttribute('data-id') === $auto->ID, 'data-id did not match'); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * Test that the default properties match what we expect |
| 59 | 59 | */ |
| 60 | - public function testLimitFilter(){ |
|
| 61 | - $this->objFromFixture('AutomatedLink','link3'); |
|
| 60 | + public function testLimitFilter() { |
|
| 61 | + $this->objFromFixture('AutomatedLink', 'link3'); |
|
| 62 | 62 | |
| 63 | 63 | $page = $this->createPage('<p>Checking if default is created only twice. default default</p>'); |
| 64 | 64 | $dom = $this->getPageDOM($page); |
@@ -74,11 +74,11 @@ discard block |
||
| 74 | 74 | * @param SiteTree $page |
| 75 | 75 | * @return DOMDocument |
| 76 | 76 | */ |
| 77 | - private function getLinkFromPage(SiteTree $page){ |
|
| 77 | + private function getLinkFromPage(SiteTree $page) { |
|
| 78 | 78 | $dom = $this->getPageDOM($page); |
| 79 | 79 | $links = $dom->getElementsByTagName('a'); |
| 80 | 80 | $this->assertTrue($links->length == 1, 'Didn\'t find the link that was suppose to be created'); |
| 81 | - return ( $links->length != 1 ) ? new DOMElement() : $links->item(0); |
|
| 81 | + return ($links->length != 1) ? new DOMElement() : $links->item(0); |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | * @param string|null $content |
| 88 | 88 | * @return Page |
| 89 | 89 | */ |
| 90 | - private function createPage($content=null){ |
|
| 91 | - $page = Page::create(array( 'Content' => $content )); |
|
| 90 | + private function createPage($content = null) { |
|
| 91 | + $page = Page::create(array('Content' => $content)); |
|
| 92 | 92 | $page->write(); |
| 93 | 93 | return $page; |
| 94 | 94 | } |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | * @param Page $page |
| 100 | 100 | * @return DOMDocument |
| 101 | 101 | */ |
| 102 | - private function getPageDOM(Page $page){ |
|
| 102 | + private function getPageDOM(Page $page) { |
|
| 103 | 103 | $controller = Page_Controller::create($page); |
| 104 | 104 | $controller->invokeWithExtensions('addAutomatedLinks'); |
| 105 | 105 | return AutomatedLink::constructDOMDocument($controller->Content); |