39 lines
940 B
PHP
39 lines
940 B
PHP
<?php
|
|
namespace nulib\cache;
|
|
|
|
use nulib\output\msg;
|
|
|
|
class CacheChannelTest extends _TestCase {
|
|
const DATA = [
|
|
"fr" => ["a" => "un", "b" => "deux"],
|
|
"eng" => ["a" => "one", "b" => "two"],
|
|
["a" => 1, "b" => 2],
|
|
];
|
|
|
|
function testUsage() {
|
|
$channel = CacheChannel::with(self::DATA, "numbers", self::$storage);
|
|
$count = 0;
|
|
foreach ($channel as $key => $item) {
|
|
msg::info("one: $key => {$item["a"]}");
|
|
$count++;
|
|
}
|
|
self::assertSame(3, $count);
|
|
}
|
|
|
|
function testAddColumns() {
|
|
$channel = (new class("numbers") extends CacheChannel {
|
|
const NAME = "numbersac";
|
|
const TABLE_NAME = self::NAME;
|
|
const ADD_COLUMNS = [
|
|
"a" => "varchar(30)",
|
|
];
|
|
})->initStorage(self::$storage)->build(self::DATA);
|
|
$count = 0;
|
|
foreach ($channel as $key => $item) {
|
|
msg::info("one: $key => {$item["a"]}");
|
|
$count++;
|
|
}
|
|
self::assertSame(3, $count);
|
|
}
|
|
}
|