Skip to content

Commit e238bcb

Browse files
author
Adam Halfar
committed
Fix tests
1 parent e81df7b commit e238bcb

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

src/Model/Entity/Panel.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ class Panel extends Entity
4747
protected function _getContent(mixed $content): string
4848
{
4949
if (is_string($content)) {
50+
// phpcs:disable
5051
$contentInflated = @gzinflate($content);
51-
if ($contentInflated) {
52+
// phpcs:enable
53+
if ($contentInflated !== false) {
5254
return $contentInflated;
5355
}
5456

@@ -72,7 +74,7 @@ protected function _setContent(mixed $content): mixed
7274
{
7375
if (is_string($content)) {
7476
$contentDeflated = gzdeflate($content, 9);
75-
if ($contentDeflated) {
77+
if ($contentDeflated !== false) {
7678
$content = $contentDeflated;
7779
}
7880
}

src/Model/Table/RequestsTable.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
declare(strict_types=1);
34

45
/**
@@ -12,6 +13,7 @@
1213
* @link https://cakephp.org CakePHP(tm) Project
1314
* @license https://www.opensource.org/licenses/mit-license.php MIT License
1415
*/
16+
1517
namespace DebugKit\Model\Table;
1618

1719
use Cake\Core\Configure;
@@ -33,8 +35,7 @@
3335
* @method \DebugKit\Model\Entity\Request[] patchEntities($entities, array $data, array $options = [])
3436
* @method \DebugKit\Model\Entity\Request findOrCreate($search, callable $callback = null, array $options = [])
3537
*/
36-
class RequestsTable extends Table
37-
{
38+
class RequestsTable extends Table {
3839
use LazyTableTrait;
3940
use SqlTraceTrait;
4041

@@ -44,8 +45,7 @@ class RequestsTable extends Table
4445
* @param array $config Config data.
4546
* @return void
4647
*/
47-
public function initialize(array $config): void
48-
{
48+
public function initialize(array $config): void {
4949
$this->hasMany('DebugKit.Panels', [
5050
'sort' => ['Panels.title' => 'ASC'],
5151
]);
@@ -62,8 +62,7 @@ public function initialize(array $config): void
6262
*
6363
* @return string
6464
*/
65-
public static function defaultConnectionName(): string
66-
{
65+
public static function defaultConnectionName(): string {
6766
return 'debug_kit';
6867
}
6968

@@ -73,8 +72,7 @@ public static function defaultConnectionName(): string
7372
* @param \Cake\ORM\Query\SelectQuery $query The query
7473
* @return \Cake\ORM\Query\SelectQuery The query.
7574
*/
76-
public function findRecent(SelectQuery $query): SelectQuery
77-
{
75+
public function findRecent(SelectQuery $query): SelectQuery {
7876
return $query->orderBy(['Requests.requested_at' => 'DESC'])
7977
->limit(10);
8078
}
@@ -84,8 +82,7 @@ public function findRecent(SelectQuery $query): SelectQuery
8482
*
8583
* @return bool
8684
*/
87-
protected function shouldGc(): bool
88-
{
85+
protected function shouldGc(): bool {
8986
return rand(1, 10) === 10;
9087
}
9188

@@ -94,8 +91,7 @@ protected function shouldGc(): bool
9491
*
9592
* @return bool
9693
*/
97-
protected function shouldGcVacuum(): bool
98-
{
94+
protected function shouldGcVacuum(): bool {
9995
return rand(1, 10) === 10;
10096
}
10197

@@ -108,8 +104,7 @@ protected function shouldGcVacuum(): bool
108104
*
109105
* @return void
110106
*/
111-
public function gc(): void
112-
{
107+
public function gc(): void {
113108
if (!$this->shouldGc()) {
114109
return;
115110
}
@@ -157,9 +152,9 @@ public function gc(): void
157152
try {
158153
$conn->execute('VACUUM;');
159154
} catch (PDOException) {
160-
if (is_file(TMP . 'debug_kit.sqlite')) {
161-
unlink(TMP . 'debug_kit.sqlite');
162-
}
155+
// phpcs:disable
156+
@unlink(TMP . 'debug_kit.sqlite');
157+
// phpcs:enable
163158
}
164159
}
165160
} catch (PDOException $e) {

0 commit comments

Comments
 (0)