Completed
Branch master (486a28)
by Paweł
02:07
created

CodeReviewAutoloaderTest::testClassExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 11
c 1
b 0
f 1
nc 2
nop 0
dl 0
loc 14
rs 9.4285
1
<?php
2
3
class CodeReviewAutoloaderTest extends PHPUnit_Framework_TestCase {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
	public function testRegister() {
6
		$autoloader = new CodeReviewAutoloader();
7
8
		$this->assertFalse($autoloader->unregister());
9
		//double register
10
		$this->assertTrue($autoloader->register());
11
		$this->assertTrue($autoloader->register());
12
		//unregister just once
13
		$this->assertTrue($autoloader->unregister());
14
		$this->assertFalse($autoloader->unregister());
15
	}
16
17
	public function testClassExists() {
18
		$classes = array(
19
			'code_review',
20
			'CodeFixer',
21
			'CodeReviewAnalyzer',
22
			'CodeReviewFileFilterIterator',
23
			'PhpFileParser',
24
			'PhpTokensFilterIterator',
25
			'CodeReview_Foo_TestClass',
26
		);
27
		foreach ($classes as $class) {
28
			$this->assertTrue(class_exists($class));
29
		}
30
	}
31
32
	public function testClassDoesNotExists() {
33
		$classes = array(
34
			'code_review_non_existing',
35
			'CodeReview_FooTestClass',
36
			'CodeReviewFoo_TestClass',
37
			'CodeReviewFooTestClass',
38
			'CodeReview/Foo/TestClass',
39
			'CodeReview_Foo/TestClass',
40
			'CodeReview/Foo_TestClass',
41
		);
42
		foreach ($classes as $class) {
43
			$this->assertFalse(class_exists($class));
44
		}
45
	}
46
47
}