Completed
Push — develop ( 17fbc1...f065be )
by Dylan
02:50
created
tests/AutomatedLinkTest.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
      * Renders the passed $page and returns all links found if any
80 80
      *
81 81
      * @param SiteTree $page
82
-     * @return DOMNameList
82
+     * @return DOMNodeList
83 83
      */
84 84
     public static function getLinksFromPage(SiteTree $page){
85 85
         $dom = self::getPageDOM($page);
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -13,8 +13,8 @@  discard block
 block discarded – undo
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,41 +23,41 @@  discard block
 block discarded – undo
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   = self::createPage('<p>Checking if properties is with correct props</p>');
30 30
         $link   = self::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   = self::createPage('<p>Checking if default is correct</p>');
46 46
         $link   = self::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(){
60
+    public function testLimitFilter() {
61 61
         $page   = self::createPage('<p>Checking if default is created only twice. default default</p>');
62 62
         $dom    = self::getPageDOM($page);
63 63
         $links  = $dom->getElementsByTagName('a');
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
     /**
68 68
      * Test that the default properties match what we expect
69 69
      */
70
-    public function testDisableFilter(){
70
+    public function testDisableFilter() {
71 71
         GlobalAutoLinkSettings::$enabled = false;
72 72
         $page   = self::createPage('<p>Checking if default is created at all when automated links are disabled.</p>');
73 73
         $links  = self::getLinksFromPage($page);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      * @param SiteTree $page
82 82
      * @return DOMNameList
83 83
      */
84
-    public static function getLinksFromPage(SiteTree $page){
84
+    public static function getLinksFromPage(SiteTree $page) {
85 85
         $dom = self::getPageDOM($page);
86 86
         return $dom->getElementsByTagName('a');
87 87
     }
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
      * @param SiteTree $page
95 95
      * @return DOMDocument
96 96
      */
97
-    public static function getLinkFromPage(SiteTree $page){
97
+    public static function getLinkFromPage(SiteTree $page) {
98 98
         $links = self::getLinksFromPage($page);
99
-        return ( $links->length != 1 ) ? new DOMElement() : $links->item(0);
99
+        return ($links->length != 1) ? new DOMElement() : $links->item(0);
100 100
     }
101 101
 
102 102
     /**
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
      * @param string|null $content
106 106
      * @return Page
107 107
      */
108
-    public static function createPage($content=null){
109
-        $page = Page::create(array( 'Content' => $content ));
108
+    public static function createPage($content = null) {
109
+        $page = Page::create(array('Content' => $content));
110 110
         $page->write();
111 111
         return $page;
112 112
     }
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
      * @param Page $page
118 118
      * @return DOMDocument
119 119
      */
120
-    public static function getPageDOM(Page $page){
120
+    public static function getPageDOM(Page $page) {
121 121
         $controller = Page_Controller::create($page);
122 122
         $controller->invokeWithExtensions('addAutomatedLinks');
123 123
         return AutomatedLink::constructDOMDocument($controller->Content);
Please login to merge, or discard this patch.
tests/GlobalAutoLinkSettingsTest.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
     /**
14 14
      * Test Max Links per page
15 15
      */
16
-    public function testMaxLinksPerPage(){
17
-        $this->objFromFixture('AutomatedLink','link');
18
-        $this->objFromFixture('AutomatedLink','link2');
19
-        $this->objFromFixture('AutomatedLink','link3');
16
+    public function testMaxLinksPerPage() {
17
+        $this->objFromFixture('AutomatedLink', 'link');
18
+        $this->objFromFixture('AutomatedLink', 'link2');
19
+        $this->objFromFixture('AutomatedLink', 'link3');
20 20
 
21 21
         $settings = GlobalAutoLinkSettings::get()->first();
22 22
         $settings->MaxLinksPerPage = 1;
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
     /**
31 31
      * Test that links are not created inside of exclude tags
32 32
      */
33
-    public function testExcludeTags(){
33
+    public function testExcludeTags() {
34 34
         $settings = GlobalAutoLinkSettings::get()->first();
35 35
         $settings->MaxLinksPerPage = 0;
36 36
         $settings->write();
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     /**
46 46
      * Test that links are included in all the specified fields
47 47
      */
48
-    public function testIncludeIn(){
48
+    public function testIncludeIn() {
49 49
         $settings = GlobalAutoLinkSettings::get()->first();
50 50
         $settings->IncludeIn = 'Content, Introduction';
51 51
         $settings->write();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 /**
83 83
  * Simple test page to test settings
84 84
  */
85
-class TestPage extends Page implements TestOnly{
85
+class TestPage extends Page implements TestOnly {
86 86
     private static $db = array(
87 87
         'Introduction' => 'HTMLText'
88 88
     );
Please login to merge, or discard this patch.