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

ClassLoaderTraitTest::testClassLoaderSuccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 1
cc 1
eloc 3
nc 1
nop 0
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