Permalink
Browse files

add a test to a wrong parameter type

  • Loading branch information...
iannsp committed Sep 1, 2011
1 parent dcdfc45 commit 934042ef11d965556cd5704e33329c96f28cd2f7
Showing with 21 additions and 288 deletions.
  1. +19 −26 tests/CacheTest.php
  2. +0 −259 tests/Cache_ContainerTest.php
  3. +2 −3 tests/Cache_Container_fileTest.php
View
@@ -27,53 +27,46 @@ protected function setUp() {
* Cleans up the environment after running a test.
*/
protected function tearDown() {
- // TODO Auto-generated CacheTest::tearDown()
-
$this->Cache = null;
parent::tearDown ();
}
- /**
- * Constructs the test case.
- */
- public function __construct() {
- }
-
/**
* Tests Cache->Cache()
*/
public function testCacheNoContainer() {
$this->Cache = New Cache('_otherContainer_');
- $this->assertType('Cache_Error', $this->Cache->container);
+ $this->assertInstanceOf('Cache_Error', $this->Cache->container);
+
}
public function testCacheCoveredContainer() {
$this->Cache = New Cache('file');
- $this->assertType('Cache_Container_file', $this->Cache->container);
+ $this->assertInstanceOf('Cache_Container_file', $this->Cache->container);
+ }
+ public function testCacheInvalidOptionType() {
+ $this->Cache = New Cache('file', 'wrong_parameter_type_need_be_array');
+ $this->assertInstanceOf('Cache_Error', $this->Cache->container);
}
-/*
/**
- * Tests Cache->_Cache()
- */
- public function test_Cache() {
- // TODO Auto-generated CacheTest->test_Cache()
- $this->markTestIncomplete ( "_Cache test not implemented" );
-
- $this->Cache->_Cache(/* parameters */);
-
+ * Test Cache setCaching
+ */
+ public function testCachegetCaching() {
+ $this->Cache = New Cache('file');
+ $this->assertTrue($this->Cache->getCaching());
+ $this->Cache->setCaching(false);
+ $this->assertFalse($this->Cache->getCaching());
}
-
/**
* Tests Cache->generateID()
*/
public function testGenerateID() {
- $this->Cache = New Cache('file');
- $name = 'samplename';
- $expectedID = '2081d6c6cc5f4593df2c149db6b30eda';
- $id = $this->Cache->generateID($name);
- $this->assertEquals($expectedID, $id);
-
+ $this->Cache = New Cache('file');
+ $name = 'samplename';
+ $expectedID = '2081d6c6cc5f4593df2c149db6b30eda';
+ $id = $this->Cache->generateID($name);
+ $this->assertEquals($expectedID, $id);
}
}
@@ -1,259 +0,0 @@
-<?php
-
-require_once 'Cache.php';
-
-require_once 'PHPUnit/Framework/TestCase.php';
-
-/**
- * Cache_Container test case.
- */
-class Cache_ContainerTest extends PHPUnit_Framework_TestCase {
-
- /**
- * @var Cache_Container
- */
- private $Cache_Container;
-
- /**
- * Prepares the environment before running a test.
- */
- protected function setUp() {
- parent::setUp ();
-
- // TODO Auto-generated Cache_ContainerTest::setUp()
-
-
- $this->Cache_Container = new Cache_Container(/* parameters */);
-
- }
-
- /**
- * Cleans up the environment after running a test.
- */
- protected function tearDown() {
- // TODO Auto-generated Cache_ContainerTest::tearDown()
-
-
- $this->Cache_Container = null;
-
- parent::tearDown ();
- }
-
- /**
- * Constructs the test case.
- */
- public function __construct() {
- // TODO Auto-generated constructor
- }
-
- /**
- * Tests Cache_Container->load()
- */
- public function testLoad() {
- // TODO Auto-generated Cache_ContainerTest->testLoad()
- $this->markTestIncomplete ( "load test not implemented" );
-
- $this->Cache_Container->load(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->getUserdata()
- */
- public function testGetUserdata() {
- // TODO Auto-generated Cache_ContainerTest->testGetUserdata()
- $this->markTestIncomplete ( "getUserdata test not implemented" );
-
- $this->Cache_Container->getUserdata(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->isExpired()
- */
- public function testIsExpired() {
- // TODO Auto-generated Cache_ContainerTest->testIsExpired()
- $this->markTestIncomplete ( "isExpired test not implemented" );
-
- $this->Cache_Container->isExpired(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->isCached()
- */
- public function testIsCached() {
- // TODO Auto-generated Cache_ContainerTest->testIsCached()
- $this->markTestIncomplete ( "isCached test not implemented" );
-
- $this->Cache_Container->isCached(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->fetch()
- */
- public function testFetch() {
- // TODO Auto-generated Cache_ContainerTest->testFetch()
- $this->markTestIncomplete ( "fetch test not implemented" );
-
- $this->Cache_Container->fetch(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->save()
- */
- public function testSave() {
- // TODO Auto-generated Cache_ContainerTest->testSave()
- $this->markTestIncomplete ( "save test not implemented" );
-
- $this->Cache_Container->save(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->remove()
- */
- public function testRemove() {
- // TODO Auto-generated Cache_ContainerTest->testRemove()
- $this->markTestIncomplete ( "remove test not implemented" );
-
- $this->Cache_Container->remove(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->flush()
- */
- public function testFlush() {
- // TODO Auto-generated Cache_ContainerTest->testFlush()
- $this->markTestIncomplete ( "flush test not implemented" );
-
- $this->Cache_Container->flush(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->idExists()
- */
- public function testIdExists() {
- // TODO Auto-generated Cache_ContainerTest->testIdExists()
- $this->markTestIncomplete ( "idExists test not implemented" );
-
- $this->Cache_Container->idExists(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->garbageCollection()
- */
- public function testGarbageCollection() {
- // TODO Auto-generated Cache_ContainerTest->testGarbageCollection()
- $this->markTestIncomplete ( "garbageCollection test not implemented" );
-
- $this->Cache_Container->garbageCollection(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->preload()
- */
- public function testPreload() {
- // TODO Auto-generated Cache_ContainerTest->testPreload()
- $this->markTestIncomplete ( "preload test not implemented" );
-
- $this->Cache_Container->preload(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->flushPreload()
- */
- public function testFlushPreload() {
- // TODO Auto-generated Cache_ContainerTest->testFlushPreload()
- $this->markTestIncomplete ( "flushPreload test not implemented" );
-
- $this->Cache_Container->flushPreload(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->setOptions()
- */
- public function testSetOptions() {
- // TODO Auto-generated Cache_ContainerTest->testSetOptions()
- $this->markTestIncomplete ( "setOptions test not implemented" );
-
- $this->Cache_Container->setOptions(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->setAllowedOptions()
- */
- public function testSetAllowedOptions() {
- // TODO Auto-generated Cache_ContainerTest->testSetAllowedOptions()
- $this->markTestIncomplete ( "setAllowedOptions test not implemented" );
-
- $this->Cache_Container->setAllowedOptions(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->hasBeenSet()
- */
- public function testHasBeenSet() {
- // TODO Auto-generated Cache_ContainerTest->testHasBeenSet()
- $this->markTestIncomplete ( "hasBeenSet test not implemented" );
-
- $this->Cache_Container->hasBeenSet(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->getAllowedOptions()
- */
- public function testGetAllowedOptions() {
- // TODO Auto-generated Cache_ContainerTest->testGetAllowedOptions()
- $this->markTestIncomplete ( "getAllowedOptions test not implemented" );
-
- $this->Cache_Container->getAllowedOptions(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->encode()
- */
- public function testEncode() {
- // TODO Auto-generated Cache_ContainerTest->testEncode()
- $this->markTestIncomplete ( "encode test not implemented" );
-
- $this->Cache_Container->encode(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->decode()
- */
- public function testDecode() {
- // TODO Auto-generated Cache_ContainerTest->testDecode()
- $this->markTestIncomplete ( "decode test not implemented" );
-
- $this->Cache_Container->decode(/* parameters */);
-
- }
-
- /**
- * Tests Cache_Container->getExpiresAbsolute()
- */
- public function testGetExpiresAbsolute() {
- // TODO Auto-generated Cache_ContainerTest->testGetExpiresAbsolute()
- $this->markTestIncomplete ( "getExpiresAbsolute test not implemented" );
-
- $this->Cache_Container->getExpiresAbsolute(/* parameters */);
-
- }
-
-}
-
@@ -19,10 +19,9 @@ class Cache_Container_fileTest extends PHPUnit_Framework_TestCase {
*/
protected function setUp() {
parent::setUp ();
- $config = Array('cache_dir'=>'/tmp/','filename_prefix'=>'test');
+ $config = Array('cache_dir'=>sys_get_temp_dir(),'filename_prefix'=>'test');
$this->allowedOptions = Array('cache_dir', 'filename_prefix', 'max_userdata_linelength');
$this->Cache_Container_file = new Cache_Container_file('file', $config);
-
}
/**
@@ -44,7 +43,7 @@ public function __construct() {
* Tests Cache_Container_file->Cache_Container_file()
*/
public function testCache_Container_file() {
- $this->assertType('Cache_Container_file', $this->Cache_Container_file);
+ $this->assertInstanceOf('Cache_Container_file', $this->Cache_Container_file);
}
public function testhasBeenSet() {

0 comments on commit 934042e

Please sign in to comment.