This shows a test case for an old caching library that I use for a project. It features simple save/load/delete functions (sadly static calls) but what I want to focus on is the test code written for this class.In my opinion the unit tests for a class should show how all functions in the class work and what to expect from that class.Recently we got this great change to show off code, so I'd like to ask you if you can read that test code, understand what the class might do and how you would improve upon it.<?phpclass DatenCacheTest extends PHPUnit_Framework_TestCase {    function testNothingFound() {        $this->assertSame(false, DatenCache::load(testNotHereCache));    }    function testSaveLoadSimple() {        $sDatenSimple = testStringSaveLoadSimple;        $sDatenSimpleParam = testStringParam;        $sDatenSimpleParam2 = testStringParam2;        $sDatenSimpleParam3 = ;        $sDatenSimpleParam4 = 0;        $this->assertSame(true, DatenCache::save(testCacheSimple, false, $sDatenSimple));        $this->assertSame($sDatenSimple, DatenCache::load(testCacheSimple, false));        $this->assertSame(true, DatenCache::save(testCacheLinearParam, string, $sDatenSimpleParam));        $this->assertSame($sDatenSimpleParam, DatenCache::load(testCacheLinearParam, string));        $this->assertSame(true, DatenCache::save(testCacheLinearParam, 5, $sDatenSimpleParam2));        $this->assertSame($sDatenSimpleParam2, DatenCache::load(testCacheLinearParam, 5));        $this->assertSame(true, DatenCache::save(testCacheBoundStringParam, false, $sDatenSimpleParam3));         $this->assertSame($sDatenSimpleParam3, DatenCache::load(testCacheBoundStringParam, false));        $this->assertSame(true, DatenCache::save(testCacheBoundIntParam, false, $sDatenSimpleParam4));        $this->assertSame($sDatenSimpleParam4, DatenCache::load(testCacheBoundIntParam, false));        $oObj = new stdClass();        $oObj->bob = 2;        $this->assertSame(true,   DatenCache::save(testCacheBoundObjParam, $oObj, zwei));        $this->assertSame(zwei, DatenCache::load(testCacheBoundObjParam, $oObj));   }    function testSaveLoadArray() {        $aDaten = array(da => ten, array(ten => da), Striche => ' \;s:5:, h''uh => mep, \\mep\\ => ^^, Zeilenumbruch => \n, Zeug => ::}}{:, ' => '', '' => ');        $this->assertSame(true, DatenCache::save(testCacheArray, false, $aDaten));        $this->assertSame($aDaten, DatenCache::load(testCacheArray, false));    }    function testSaveLoadExpired() {        $this->assertSame(true,  DatenCache::save(testCacheExpired, false, testStringLoadExpired, -1 seconds));        $this->assertSame(false, DatenCache::load(testCacheExpired, false));    }    function testSaveLoadObject() {        $oObj = new stdClass();        $oObj->bob = 2;        $this->assertSame(true, DatenCache::save(testCacheBoundIntParam, false, $oObj));        $oNewObj = DatenCache::load(testCacheBoundIntParam, false);        $this->assertEquals($oObj, $oNewObj);        $this->assertSame($oObj->bob, $oNewObj->bob);    }    function testSaveLoadComplexParam() {        $aKonfigEins  = array(DatenCache::ANLAGEN_ID() => 1, DatenCache::SESSION_ID() => id1);        $aKonfigZwei  = array(DatenCache::ANLAGEN_ID() => 1, DatenCache::SESSION_ID() => id2);        $aKonfigDrei  = array(DatenCache::ANLAGEN_ID() => 1, DatenCache::SESSION_ID() => id3);        $aKonfigVier  = array(DatenCache::ANLAGEN_ID() => 1);        $aKonfigFuenf = array(DatenCache::SESSION_ID() => id3);        $aKonfigSechs = array(DatenCache::ANLAGEN_ID() => 1, DatenCache::SESSION_ID() => id3, DatenCache::PERSON_ID() => 1);        $this->assertSame(true, DatenCache::save(testCacheComplexParam, $aKonfigEins, v1));        $this->assertSame(v1, DatenCache::load(testCacheComplexParam, $aKonfigEins));        $this->assertSame(true, DatenCache::save(testCacheComplexParam, $aKonfigZwei, v2));        $this->assertSame(v2, DatenCache::load(testCacheComplexParam, $aKonfigZwei));        $this->assertSame(false, DatenCache::load(testCacheComplexParam, $aKonfigDrei));        $this->assertSame(false, DatenCache::load(testCacheComplexParam, $aKonfigVier));        $this->assertSame(false, DatenCache::load(testCacheComplexParam, $aKonfigFuenf));        $this->assertSame(false, DatenCache::load(testCacheComplexParam, $aKonfigSechs));    }    function testInvalidate() {        $this->assertSame(true, DatenCache::save(testCacheSimple, false, testStringInvalidate));        DatenCache::invalidate(testCacheSimple);        $this->assertSame(false, DatenCache::load(testCacheSimple, false));    }    function testInvalidateWithParams() {        $sTestStringEins = testStringInvalidateWithParams;        $sTestStringZwei = testStringInvalidateWithParamsZwei;        $aKonfigEins = array(DatenCache::ANLAGEN_ID() => 1, Pony => false);        $aKonfigZwei = array(DatenCache::ANLAGEN_ID() => 1, Pony => true);        $this->assertSame(true, DatenCache::save(testCacheInvalidateWithParams, $aKonfigEins, $sTestStringEins));        $this->assertSame(true, DatenCache::save(testCacheInvalidateWithParams, $aKonfigZwei, $sTestStringEins));        DatenCache::invalidate(testCacheInvalidateWithParams, $aKonfigEins);        $this->assertSame(false, DatenCache::load(testCacheInvalidateWithParams, $aKonfigEins));        $this->assertSame($sTestStringEins, DatenCache::load(testCacheInvalidateWithParams, $aKonfigZwei));        $aKonfigDrei = array(DatenCache::ANLAGEN_ID() => 1, DatenCache::BENUTZER_ID() => 123, bob => please);        $aKonfigVier = array(DatenCache::ANLAGEN_ID() => 2, Pony => true, bob => please);        $aPartEins   = array(DatenCache::ANLAGEN_ID() => 1);        $aPartZwei   = array(DatenCache::BENUTZER_ID() => 123);        $aPartDrei   = array(bob  => please);        $this->assertSame(true,  DatenCache::save(testCacheInvalidateWithParams, $aKonfigDrei, $sTestStringZwei.1));        DatenCache::invalidate(testCacheInvalidateWithParams, $aPartEins);        $this->assertSame(false, DatenCache::load(testCacheInvalidateWithParams, $aKonfigDrei));        $this->assertSame(true,  DatenCache::save(testCacheInvalidateWithParams, $aKonfigDrei, $sTestStringZwei.2));              DatenCache::invalidate(testCacheInvalidateWithParams, $aPartZwei);        $this->assertSame(false, DatenCache::load(testCacheInvalidateWithParams, $aKonfigDrei));        $this->assertSame(true,  DatenCache::save(testCacheInvalidateWithParams, $aKonfigDrei, $sTestStringZwei.3));        DatenCache::invalidate(testCacheInvalidateWithParams, $aPartDrei);        $this->assertSame(false, DatenCache::load(testCacheInvalidateWithParams, $aKonfigDrei));        $this->assertSame(true,  DatenCache::save(testCacheInvalidateWithParams, $aKonfigEins, $sTestStringEins));        $this->assertSame(true,  DatenCache::save(testCacheInvalidateWithParams, $aKonfigZwei, $sTestStringEins));        $this->assertSame(true,  DatenCache::save(testCacheInvalidateWithParams, $aKonfigDrei, $sTestStringEins));        DatenCache::invalidate(testCacheInvalidateWithParams, array(DatenCache::ANLAGEN_ID() => 1));        $this->assertSame(false, DatenCache::load(testCacheInvalidateWithParams, $aKonfigEins));        $this->assertSame(false, DatenCache::load(testCacheInvalidateWithParams, $aKonfigZwei));        $this->assertSame(false, DatenCache::load(testCacheInvalidateWithParams, $aKonfigDrei));        $this->assertSame(true,  DatenCache::save(testCacheInvalidateWithParams, $aKonfigEins, $sTestStringEins));        $this->assertSame(true,  DatenCache::save(testCacheInvalidateWithParams, $aKonfigVier, $sTestStringEins));        DatenCache::invalidate(testCacheInvalidateWithParams, array(DatenCache::ANLAGEN_ID() => 1));        $this->assertSame(false, DatenCache::load(testCacheInvalidateWithParams, $aKonfigEins));        $this->assertSame($sTestStringEins, DatenCache::load(testCacheInvalidateWithParams, $aKonfigVier));    }    function testCleanup() {        $this->assertSame(true, DatenCache::save(testCacheSimple,       false, testString, -5 seconds));        $this->assertSame(true, DatenCache::save(testCacheSimpleBleibt, false, testString, +30 seconds));        DatenCache::cleanup();        $this->assertSame(testString, DatenCache::load(testCacheSimpleBleibt, false));        $this->assertSame(false, DatenCache::load(testCacheSimple, false));        // Direkt auf der DB Prfen ob der Datensatz wiklich gelscht wurde und nicht nur ausgelaufen ist        $this->assertSame(            array(),            McDb::getConnection(DB_MC_CACHES)->getRow(                SELECT * FROM mc_caches.T_DATEN_CACHE WHERE PARAMETER = ? AND VALUE = ?, NAME, testCacheSimple            )        );    }    function testCleanupWithParam() {        $aKonfig = array(DatenCache::ANLAGEN_ID() => 1);        $this->assertSame(true, DatenCache::save(testCacheSimple, $aKonfig, testString, +120 seconds));        DatenCache::cleanup();        $this->assertSame(testString, DatenCache::load(testCacheSimple, $aKonfig));    }    function testInvalidateByParam() {        $mValue1 = 1;        $mValue2 = 2;        $aKonfigEins = array(DatenCache::ANLAGEN_ID() => $mValue1);        $aKonfigZwei = array(DatenCache::ANLAGEN_ID() => $mValue2);        $this->assertSame(true, DatenCache::save(testCacheInvalidateByParam,  $aKonfigEins, testString));        $this->assertSame(true, DatenCache::save(testCacheInvalidateByParam2, $aKonfigZwei, testString2));        DatenCache::invalidateByParam(DatenCache::ANLAGEN_ID());        $this->assertSame(false, DatenCache::load(testCacheInvalidateByParam,  $aKonfigEins));        $this->assertSame(false, DatenCache::load(testCacheInvalidateByParam2, $aKonfigZwei));        $this->assertSame(true, DatenCache::save(testCacheSimple,  $aKonfigEins, testString));        $this->assertSame(true, DatenCache::save(testCacheSimple2, $aKonfigZwei, testString2));        DatenCache::invalidateByParam(DatenCache::ANLAGEN_ID(), $mValue1);        $this->assertSame(false, DatenCache::load(testCacheSimple,  $aKonfigEins));        $this->assertSame(testString2, DatenCache::load(testCacheSimple2, $aKonfigZwei));    }    function testInvalidateByParamLike() {        $mValue1 = I wan't a Pony;        $mValue2 = No Pony for you !;        $mValue3 = xxx;        $this->assertSame(true, DatenCache::save(PonyCache, array(PonyParam => $mValue1), test1));        $this->assertSame(true, DatenCache::save(PonyCache, array(PonyParam => $mValue2), test2));        $this->assertSame(true, DatenCache::save(PonyCache, array(PonyParam => $mValue3), test3));        DatenCache::invalidateByParam(PonyParam, %Pony%, true);        $this->assertSame(false,   DatenCache::load(PonyCache, array(PonyParam => $mValue1)));        $this->assertSame(false,   DatenCache::load(PonyCache, array(PonyParam => $mValue2)));        $this->assertSame(test3, DatenCache::load(PonyCache, array(PonyParam => $mValue3)));    }    /**     * @expectedException PHPUnit_Framework_Error     */    function testInvalidSaveTime() {        $this->assertSame(false, DatenCache::save(testFail, null, test1, invalidStrtotime));    }    function testInvalidSaveTimeReturn() {        $this->assertSame(false, @DatenCache::save(testFail, null, test1, invalidStrtotime));    }}
Test case for a caching library
php;unit testing;cache
Other than long lines, I'm not seeing something too unreadable.  I don't advise shortening function names as doing so makes it less clear what the function is doing.  Instead, try splitting the function calls being passed as parameters onto different lines by either splitting the line across multiple lines or storing the returned value as a variable and passing that variable in.