Completed
Push — master ( ff3baa...f20332 )
by smiley
03:25
created

ClassLoaderTraitTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 25
rs 10
c 1
b 0
f 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testClassLoaderSuccess() 0 4 1
A testClassLoaderDoesNotImplementException() 0 3 1
A testClassLoaderDoesNotExistException() 0 3 1
1
<?php
2
/**
3
 *
4
 * @filesource   ClassLoaderTraitTest.php
5
 * @created      29.02.2016
6
 * @package      chillerlan\DatabaseTest\Traits
7
 * @author       Smiley <[email protected]>
8
 * @copyright    2015 Smiley
9
 * @license      MIT
10
 */
11
12
namespace chillerlan\DatabaseTest\Traits;
13
14
use chillerlan\Database\DBOptions;
15
use chillerlan\Database\Drivers\DBDriverInterface;
16
use chillerlan\Database\Drivers\MySQLi\MySQLiDriver;
17
use chillerlan\Database\Traits\ClassLoaderTrait;
18
19
class ClassLoaderTraitTest extends \PHPUnit_Framework_TestCase{
20
	use ClassLoaderTrait;
21
22
	public function testClassLoaderSuccess(){
23
		$dbdriver = $this->__loadClass(MySQLiDriver::class, DBDriverInterface::class, new DBOptions);
24
		$this->assertInstanceOf(DBDriverInterface::class, $dbdriver);
25
	}
26
27
	/**
28
	 * @expectedException \chillerlan\Database\DBException
29
	 * @expectedExceptionMessage chillerlan\Database\Drivers\MySQLi\MySQLiDriver does not implement chillerlan\DatabaseTest\Traits\TestInterface
30
	 */
31
	public function testClassLoaderDoesNotImplementException(){
32
		$this->__loadClass(MySQLiDriver::class, TestInterface::class);
33
	}
34
35
	/**
36
	 * @expectedException \chillerlan\Database\DBException
37
	 * @expectedExceptionMessage Interface whatevs does not exist
38
	 */
39
	public function testClassLoaderDoesNotExistException(){
40
		$this->__loadClass(MySQLiDriver::class, 'whatevs');
41
	}
42
43
}
44