SimpleInMemoryCacheTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 41
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSetAndGetOneValue() 0 16 1
A valueProvider() 0 17 1
1
<?php
2
3
namespace SimpleCache\Tests\Phpunit\Cache;
4
5
use SimpleCache\Cache\SimpleInMemoryCache;
6
7
/**
8
 * @covers SimpleCache\Cache\SimpleInMemoryCache
9
 *
10
 * @licence GNU GPL v2+
11
 * @author Jeroen De Dauw < [email protected] >
12
 */
13
class SimpleInMemoryCacheTest extends \PHPUnit_Framework_TestCase {
14
15
	/**
16
	 * @dataProvider valueProvider
17
	 */
18
	public function testSetAndGetOneValue( $value ) {
19
		$key = 'foo';
20
21
		$cache = new SimpleInMemoryCache();
22
23
		$this->assertFalse( $cache->has( $key ) );
24
25
		$cache->set( $key, $value );
26
27
		$this->assertEquals(
28
			$value,
29
			$cache->get( $key )
30
		);
31
32
		$this->assertTrue( $cache->has( $key ) );
33
	}
34
35
	public function valueProvider() {
36
		$argLists = array();
37
38
		$argLists[] = array( true );
39
		$argLists[] = array( false );
40
		$argLists[] = array( 0 );
41
		$argLists[] = array( '' );
42
		$argLists[] = array( '1' );
43
		$argLists[] = array( '0' );
44
		$argLists[] = array( 'foo bar baz bah' );
45
		$argLists[] = array( array() );
46
		$argLists[] = array( (object)array() );
47
		$argLists[] = array( (object)array( 'foo' => 'bar' ) );
48
		$argLists[] = array( array( 42, 4 => '2', 13.37 ) );
49
50
		return $argLists;
51
	}
52
53
}
54