Completed
Push — master ( cf174f...e60a6a )
by Mia
04:35
created

CRSSFeedTest::testGetFeed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 9 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * A test class for testing RSSFeed class
4
 * 
5
 */
6
7
namespace Miax\RSSFeed;
8
use SimplePie;
9
define('CACHE', __DIR__.'/../webroot/cache/');
10
require_once(__DIR__."/simplepie/simplepie_1.3.1.mini.php");
11
12
      
13
class CRSSFeedTest extends \PHPUnit_Framework_TestCase {
14
	
15
	
16
	/** -------------------------------------------------------
17
     * Test 1
18
	 *  
19
     */ 
20
	/*public function testGetFeed(){
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
21
		$feed = new \Miax\RSSFeed\CRSSFeed('test');
22
		$res = $el['name'];
23
		$exp = 'test';
24
		$this->assertEquals($res, $exp, "Created element name missmatch.");
25
	}
26
	
27
	*/
28
	
29
	/** ---------------------------------------------------------
30
     * Test 2 Mock of SimplePie  
31
     * 
32
     */ 
33
	 
34
	//private $rss;
35
36
  
37
	/*public function setUp(){
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
		$feed = new SimplePie();
39
		$feed = getFeed('http://feeds.feedburner.com/idg/vzzs/');
40
		$rss = new Miax\RSSFeed\CRSSFeed($feed);
41
		
42
	}
43
	
44
	public function tearDown(){
45
		
46
	}
47
	
48
	public function testCorrectFeed() {
49
        $this->assertTrue(
50
            $this->rss->getFeed('http://feeds.feedburner.com/idg/vzzs/'),
51
            "Expecting successful result"
52
            ); echo setVerboseErrorHandler();
53
			
54
    }
55
	
56
	public function testFalseFeed(){
57
		$feed = $this->getMock("SimplePie");
58
		$this->rss = new Miax\RSSFeed\CRSSFeed($feed);
59
			 ->method('get_items')
60
			 ->with($this->equalTo('/../webroot/cache/','http://feeds.feedburner.com/idg/vzzs/', 3600));
61
		
62
		$feed->expects($this->once())
63
			 ->method('getTitle')
64
			 ->with($this->equalTo('Senaste nytt från IDG'));
65
			 
66
		
67
		$feed->expects($this->once())
68
		$this->rss->getFeed("http://feeds.feedburner.com/idg/vzzs/", "wrong");
69
	}
70
	*/
71
	
72
	/** ---------------------------------------------------------
73
     * Test 3  
74
     * 
75
     */ 
76
	
77
	/*protected function setVerboseErrorHandler(){
0 ignored issues
show
Unused Code Comprehensibility introduced by
66% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
78
		$handler = function($errorNumber, $errorString, $errorFile, $errorLine) {
79
			echo "
80
			ERROR INFO
81
			Message: $errorString
82
			File: $errorFile
83
			Line: $errorLine
84
			";
85
		};
86
		set_error_handler($handler);        
87
	}*/
88
	
89
	/* public function testGetFeed() { 
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
90
		 $feed = new Miax\RSSFeed\CRSSFeed(['http://feeds.feedburner.com/idg/vzzs/']); 
91
		 $content = $this->feed->getFeed(); 
92
		 $this->assertEqual($feed, $content, "Return type is not a valid type"); 
93
		// echo setVerboseErrorHandler();
94
  	}*/
95
  
96
	
97
	/** ---------------------------------------------------------
98
     * Test test  
99
     * 
100
     */ 
101
	
102
	
103
	public function testTesting() {
104
    $this->assertEquals(1, 1, "Just making sure this is being checked.");
105
 	}
106
	 
107
}