Skip to content

Commit 1a63f25

Browse files
committed
fix: unity tests
1 parent 029a3dd commit 1a63f25

5 files changed

Lines changed: 17 additions & 17 deletions

File tree

src/Cache/Adapters/DatabaseAdapter.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function add(string $key, mixed $data, ?int $time = null): bool
6262

6363
$time = date("Y-m-d H:i:s");
6464

65-
return $this->query->insert(['keyname' => $key, "data" => serialize($content), "expire" => $time]);
65+
return $this->query->insert(['key_name' => $key, "data" => serialize($content), "expire" => $time]);
6666
}
6767

6868
/**
@@ -71,7 +71,7 @@ public function add(string $key, mixed $data, ?int $time = null): bool
7171
*/
7272
public function has(string $key): bool
7373
{
74-
return $this->query->where("keyname", $key)->exists();
74+
return $this->query->where("key_name", $key)->exists();
7575
}
7676

7777
/**
@@ -91,14 +91,14 @@ public function update(string $key, mixed $data, ?int $time = null): mixed
9191
$content = $data;
9292
}
9393

94-
$result = $this->query->where("keyname", $key)->first();
94+
$result = $this->query->where("key_name", $key)->first();
9595
$result->data = serialize($content);
9696

9797
if (!is_null($time)) {
9898
$result->expire = date("Y-m-d H:i:s", strtotime($result->expire) + $time);
9999
}
100100

101-
return $this->query->where("keyname", $key)->update((array)$result);
101+
return $this->query->where("key_name", $key)->update((array)$result);
102102
}
103103

104104
/**
@@ -135,12 +135,12 @@ public function push(string $key, array $data): bool
135135
throw new Exception("The key $key is not found");
136136
}
137137

138-
$result = $this->query->where("keyname", $key)->first();
138+
$result = $this->query->where("key_name", $key)->first();
139139

140140
$value = (array)unserialize($result->data);
141141
$result->data = serialize(array_merge($value, $data));
142142

143-
return (bool)$this->query->where("keyname", $key)->update((array)$result);
143+
return (bool)$this->query->where("key_name", $key)->update((array)$result);
144144
}
145145

146146
/**
@@ -154,11 +154,11 @@ public function addTime(string $key, int $time): bool
154154
throw new Exception("The key $key is not found");
155155
}
156156

157-
$result = $this->query->where("keyname", $key)->first();
157+
$result = $this->query->where("key_name", $key)->first();
158158

159159
$result->expire = date("Y-m-d H:i:s", strtotime($result->expire) + $time);
160160

161-
return (bool)$this->query->where("keyname", $key)->update((array)$result);
161+
return (bool)$this->query->where("key_name", $key)->update((array)$result);
162162
}
163163

164164
/**
@@ -172,7 +172,7 @@ public function timeOf(string $key): int|bool|string
172172
throw new Exception("The key $key is not found");
173173
}
174174

175-
$result = $this->query->where("keyname", $key)->first();
175+
$result = $this->query->where("key_name", $key)->first();
176176

177177
return $result->expire;
178178
}
@@ -188,7 +188,7 @@ public function forget(string $key): bool
188188
throw new Exception("The key $key is not found");
189189
}
190190

191-
return $this->query->where("keyname", $key)->delete();
191+
return $this->query->where("key_name", $key)->delete();
192192
}
193193

194194
/**
@@ -210,7 +210,7 @@ public function get(string $key, mixed $default = null): mixed
210210
return is_callable($default) ? $default() : $default;
211211
}
212212

213-
$result = $this->query->where("keyname", $key)->first();
213+
$result = $this->query->where("key_name", $key)->first();
214214

215215
$value = unserialize($result->data);
216216

src/Console/stubs/model/cache.stub

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class {className} extends Migration
1111
public function up(): void
1212
{
1313
$this->create("caches", function (Table $table) {
14-
$table->addString('keyname', ['primary' => true, 'size' => 500]);
14+
$table->addString('key_name', ['primary' => true, 'size' => 500]);
1515
$table->addText('data');
1616
$table->addDatetime('expire', ['nullable' => true]);
1717
$table->addTimestamps();

tests/Cache/CacheDatabaseTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ public static function setUpBeforeClass(): void
1414

1515
Database::configure($config["database"]);
1616

17-
Database::statement("drop table if exists caches;");
17+
Database::statement("DROP TABLE IF EXISTS caches;");
1818
Database::statement("
19-
create table if not exists caches (
20-
keyname varchar(500) not null primary key,
19+
CREATE TABLE IF NOT EXISTS caches (
20+
key_name varchar(500) not null primary key,
2121
data text null,
2222
expire datetime null
2323
)");

tests/Console/__snapshots__/GeneratorDeepTest__test_generate_cache_migration_stubs__1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class FakeCacheMigration extends Migration
1111
public function up(): void
1212
{
1313
$this->create("caches", function (Table $table) {
14-
$table->addString('keyname', ['primary' => true, 'size' => 500]);
14+
$table->addString('key_name', ['primary' => true, 'size' => 500]);
1515
$table->addText('data');
1616
$table->addDatetime('expire', ['nullable' => true]);
1717
$table->addTimestamps();

tests/Console/__snapshots__/GeneratorDeepTest__test_generate_model_cache_stubs__1.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class FakeCacheMigration extends Migration
1111
public function up(): void
1212
{
1313
$this->create("caches", function (SQLGenerator $table) {
14-
$table->addString('keyname', ['primary' => true, 'size' => 500]);
14+
$table->addString('key_name', ['primary' => true, 'size' => 500]);
1515
$table->addText('data');
1616
$table->addDatetime('expire', ['nullable' => true]);
1717
$table->addTimestamps();

0 commit comments

Comments
 (0)