Author: Tobias Schlitt
Date: 2006-01-24 17:09:47 +0100 (Tue, 24 Jan 2006)
New Revision: 2019
Log:
- Added test case for ezcCacheStorageFile::countDataItems().
- Removed change from last commit for unique attributes (fixed by using the ID
instead of microtime()).
Modified:
packages/Cache/trunk/tests/storage_file_test.php
packages/Cache/trunk/tests/storage_test.php
Modified: packages/Cache/trunk/tests/storage_file_test.php
===================================================================
--- packages/Cache/trunk/tests/storage_file_test.php 2006-01-24 16:09:20 UTC
(rev 2018)
+++ packages/Cache/trunk/tests/storage_file_test.php 2006-01-24 16:09:47 UTC
(rev 2019)
@@ -51,6 +51,34 @@
}
}
+ public function testCountDataItems()
+ {
+ $cache = new ezcCacheStorageFileArray( $this->createTempDir(
'ezcCacheStorageFileTest' ), array( 'extension' => '.c' ) );
+ $data = array(
+ array(
+ 'attributes' => array( 'lang' => 'en', 'section' => 'articles'
),
+ 'content' => array( 'lang' => 'en', 'section' => 'articles'
),
+ ),
+ array(
+ 'attributes' => array( 'lang' => 'de', 'section' => 'articles'
),
+ 'content' => array( 'lang' => 'de', 'section' => 'articles'
),
+ ),
+ array(
+ 'attributes' => array( 'lang' => 'no', 'section' => 'articles'
),
+ 'content' => array( 'lang' => 'no', 'section' => 'articles'
),
+ )
+ );
+ foreach ( $data as $id => $dataArr )
+ {
+ $cache->store( $id, $dataArr['content'], $dataArr['attributes'] );
+ }
+
+ $this->assertEquals( $cache->countDataItems( 0 ), 1, 'Count data items
failed with ID.' );
+ $this->assertEquals( $cache->countDataItems( null, array( 'lang' =>
'no' ) ), 1, 'Count data items failed with attribute <lang>.' );
+ $this->assertEquals( $cache->countDataItems( null, array( 'section' =>
'articles' ) ), 3, 'Count data items failed with attribute <articles>.' );
+
+ }
+
public static function suite()
{
return new ezcTestSuite( "ezcCacheStorageFileTest" );
Modified: packages/Cache/trunk/tests/storage_test.php
===================================================================
--- packages/Cache/trunk/tests/storage_test.php 2006-01-24 16:09:20 UTC (rev
2018)
+++ packages/Cache/trunk/tests/storage_test.php 2006-01-24 16:09:47 UTC (rev
2019)
@@ -119,7 +119,7 @@
$attributes = array(
'name' => 'test',
'title' => 'Test item',
- 'date' => (string)microtime( true ),
+ 'date' => time().$id,
);
$this->storage->store( $id, $dataArr, $attributes );
$this->assertEquals( $this->storage->countDataItems( $id,
$attributes ), 1, 'Storage file does not exist for ID: <' . $id . '>.' );
@@ -209,7 +209,7 @@
$attributes = array(
'name' => 'test',
'title' => 'Test item',
- 'date' => (string)microtime( true ),
+ 'date' => time().$id,
);
$this->storage->store( $id, $dataArr, $attributes );
$data = $this->storage->restore( $id, $attributes );
@@ -233,7 +233,7 @@
$this->storage->store( $id, $dataArr );
// Faking the m/a-time to be 100 seconds in the past
- touch( $filename, ( (string)microtime( true ) - 100 ), (
(string)microtime( true ) - 100 ) );
+ touch( $filename, ( time() - 100 ), ( time() - 100 ) );
// Wait for cache to be outdated.
$data = $this->storage->restore( $id );
@@ -256,14 +256,14 @@
$attributes = array(
'name' => 'test',
'title' => 'Test item',
- 'date' => (string)microtime( true ),
+ 'date' => time().$id,
);
$filename = $this->storage->getLocation() .
$this->storage->generateIdentifier( $id, $attributes );
$this->storage->store( $id, $dataArr, $attributes );
// Faking the m/a-time to be 100 seconds in the past
- touch( $filename, ( (string)microtime( true ) - 100 ), (
(string)microtime( true ) - 100 ) );
+ touch( $filename, ( time() - 100 ), ( time() - 100 ) );
$data = $this->storage->restore( $id, $attributes );
$this->assertTrue( $data === false, "Restore data broken for ID
<{$id}>." );
@@ -286,7 +286,7 @@
$this->storage->store( $id, $dataArr );
// Faking the m/a-time to be 5 seconds in the past
- touch( $filename, ( (string)microtime( true ) - 5 ), (
(string)microtime( true ) - 5 ) );
+ touch( $filename, ( time() - 5 ), ( time() - 5 ) );
$data = $this->storage->restore( $id );
$this->assertTrue( $data == $dataArr, "Restore data broken for ID
<{$id}>." );
@@ -307,14 +307,14 @@
$attributes = array(
'name' => 'test',
'title' => 'Test item',
- 'date' => (string)microtime( true ),
+ 'date' => time().$id,
);
$filename = $this->storage->getLocation() .
$this->storage->generateIdentifier( $id, $attributes );
$this->storage->store( $id, $dataArr, $attributes );
// Faking the m/a-time to be 5 seconds in the past
- touch( $filename, ( (string)microtime( true ) - 5 ), (
(string)microtime( true ) - 5 ) );
+ touch( $filename, ( time() - 5 ), ( time() - 5 ) );
$data = $this->storage->restore( $id, $attributes );
$this->assertTrue( $data == $dataArr, "Restore data broken for ID
<{$id}>." );
@@ -349,7 +349,7 @@
$attributes = array(
'name' => 'test',
'title' => 'Test item',
- 'date' => (string)microtime( true ),
+ 'date' => time().$id,
);
$this->storage->store( $id, $dataArr, $attributes );
$this->storage->delete( $id, $attributes );
@@ -368,7 +368,7 @@
$attributes = array(
'name' => 'test',
'title' => 'Test item',
- 'date' => (string)microtime( true ),
+ 'date' => time(),
);
foreach ( $this->data as $id => $dataArr )
{
@@ -408,7 +408,7 @@
$attributes = array(
'name' => 'test',
'title' => 'Test item',
- 'date' => (string)microtime( true ),
+ 'date' => time().$id,
);
$this->storage->store( $id, $dataArr, $attributes );
$this->assertTrue( $this->storage->countDataItems( $id,
$attributes ) == 1, "countDataItems cannot find data for ID <{$id}>." );
@@ -427,7 +427,7 @@
$attributes = array(
'name' => 'test',
'title' => 'Test item',
- 'date' => (string)microtime( true ).$id,
+ 'date' => time().$id,
);
$this->storage->store( $id, $dataArr, $attributes );
$this->assertTrue( $this->storage->countDataItems( null,
$attributes ) == 1, "countDataItems cannot find data for ID <{$id}>." );
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components