Skip to content

Commit d4516b0

Browse files
committed
test(output_modules): update button styles in message controls and search content tests
1 parent 053f7b2 commit d4516b0

File tree

7 files changed

+18
-52
lines changed

7 files changed

+18
-52
lines changed

tests/phpunit/bootstrap.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@
2020
/* cache id */
2121
define('CACHE_ID', 'asdf');
2222

23-
/* get mock objects */
24-
require APP_PATH.'tests/phpunit/mocks.php';
2523

2624
/* get the framework */
2725
require APP_PATH.'lib/framework.php';
2826

27+
/* get mock objects */
28+
require APP_PATH.'tests/phpunit/mocks.php';
29+
2930
/* get the stubs */
3031
require APP_PATH.'tests/phpunit/stubs.php';
3132

tests/phpunit/lib/ini_set.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ class Hm_Test_Ini_Set extends TestCase {
1616
private $originalIniValues = [];
1717

1818
public function setUp(): void {
19-
if (!defined('APP_PATH')) {
20-
require_once __DIR__.'/../bootstrap.php';
21-
}
19+
require __DIR__.'/../bootstrap.php';
2220

2321
$this->storeOriginalIniValues();
2422
}

tests/phpunit/lib/scram_authenticator.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ class Hm_Test_Scram_Authenticator extends TestCase {
1616
private $scram;
1717

1818
public function setUp(): void {
19-
if (!defined('APP_PATH')) {
20-
require_once __DIR__.'/../bootstrap.php';
21-
}
19+
require __DIR__.'/../bootstrap.php';
2220

2321
// Mock Hm_Debug if it doesn't exist
2422
if (!class_exists('Hm_Debug', false)) {

tests/phpunit/lib/searchable.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,8 @@
1313
class Hm_Test_Searchable extends TestCase {
1414

1515
public function setUp(): void {
16-
if (!defined('APP_PATH')) {
17-
require_once __DIR__.'/../bootstrap.php';
18-
}
19-
// Load mocks first
20-
if (!class_exists('Hm_Mock_Session', false)) {
21-
require_once APP_PATH.'tests/phpunit/mocks.php';
22-
}
23-
24-
Mock_Searchable_Entity::resetTestData();
25-
16+
require __DIR__.'/../bootstrap.php';
17+
Mock_Searchable_Entity::resetTestData();
2618
}
2719

2820
/**

tests/phpunit/mocks.php

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -190,34 +190,8 @@ public function __construct($type) {
190190
}
191191
}
192192

193-
trait Mock_Searchable {
194-
/**
195-
* Return items matching $match in column $column.
196-
*
197-
* @param mixed $match
198-
* @param string $column
199-
* @param bool $returnFirst
200-
* @return array|null
201-
*/
202-
public static function getBy($match, $column = 'id', $returnFirst = false) {
203-
$results = [];
204-
foreach (static::getDataset() as $item) {
205-
if (isset($item[$column]) && $item[$column] === $match) {
206-
if ($returnFirst) {
207-
return $item;
208-
}
209-
$results[] = $item;
210-
}
211-
}
212-
return $returnFirst ? null : $results;
213-
}
214-
215-
// Each class must implement this
216-
abstract protected static function getDataset();
217-
}
218-
219193
class Mock_Searchable_Entity {
220-
use Mock_Searchable;
194+
use Searchable;
221195

222196
private static $testData = [
223197
['id' => 1, 'name' => 'John Doe', 'email' => '[email protected]', 'status' => 'active', 'age' => 30],
@@ -256,7 +230,7 @@ public static function setTestData(array $data) {
256230
}
257231

258232
class Mock_Empty_Searchable_Entity {
259-
use Mock_Searchable;
233+
use Searchable;
260234

261235
protected static function getDataset() {
262236
return [];
@@ -316,6 +290,7 @@ function error_resp($data) {
316290
return $pre." BAD Error in IMAP command received by server.\r\n";
317291
}
318292
}
293+
if (!class_exists('Hm_Functions')) {
319294
class Hm_Functions {
320295
public static $resource = false;
321296
public static $rand_bytes = 'good';
@@ -398,6 +373,7 @@ public static function stream_socket_enable_crypto($socket, $type) {
398373
return true;
399374
}
400375
}
376+
}
401377
function setup_db($config) {
402378
require_once __DIR__.'/bootstrap.php';
403379
$config->set('db_connection_type', env('DB_CONNECTION_TYPE', 'host'));

tests/phpunit/modules/core/message_list_functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function test_icon_callback() {
107107
*/
108108
public function test_message_controls() {
109109
$mod = new Hm_Output_Test(array('msg_controls_extra' => 'foo', 'foo' => 'bar', 'bar' => 'foo'), array('bar'));
110-
$this->assertEquals('<a class="toggle_link" href="#"><i class="bi bi-check-square-fill"></i></a><div class="msg_controls fs-6 d-none gap-1 align-items-center"><div class="dropdown on_mobile"><button type="button" class="btn btn-outline-success btn-sm dropdown-toggle" id="coreMsgControlDropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true">Actions</button><ul class="dropdown-menu" aria-labelledby="coreMsgControlDropdown"><li><a class="dropdown-item msg_read core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="read">Read</a></li><li><a class="dropdown-item msg_unread core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="unread">Unread</a></li><li><a class="dropdown-item msg_flag core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="flag">Flag</a></li><li><a class="dropdown-item msg_unflag core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="unflag">Unflag</a></li><li><a class="dropdown-item msg_delete core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="delete">Delete</a></li><li><a class="dropdown-item msg_archive core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="archive">Archive</a></li><li><a class="dropdown-item msg_junk core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="junk">Junk</a></li></ul></div><a class="msg_read core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="read">Read</a><a class="msg_unread core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="unread">Unread</a><a class="msg_flag core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="flag">Flag</a><a class="msg_unflag core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="unflag">Unflag</a><a class="msg_delete core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="delete">Delete</a><a class="msg_archive core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="archive">Archive</a><a class="msg_junk core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="junk">Junk</a>foo</div>', message_controls($mod));
110+
$this->assertEquals('<a class="toggle_link" href="#"><i class="bi bi-check-square-fill"></i></a><div class="msg_controls fs-6 d-none gap-1 align-items-center"><div class="dropdown on_mobile"><button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" id="coreMsgControlDropdown" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="true">Actions</button><ul class="dropdown-menu" aria-labelledby="coreMsgControlDropdown"><li><a class="dropdown-item msg_read core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="read">Read</a></li><li><a class="dropdown-item msg_unread core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="unread">Unread</a></li><li><a class="dropdown-item msg_flag core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="flag">Flag</a></li><li><a class="dropdown-item msg_unflag core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="unflag">Unflag</a></li><li><a class="dropdown-item msg_delete core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="delete">Delete</a></li><li><a class="dropdown-item msg_archive core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="archive">Archive</a></li><li><a class="dropdown-item msg_junk core_msg_control btn btn-sm btn-light text-black-50" href="#" data-action="junk">Junk</a></li></ul></div><a class="msg_read core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="read">Read</a><a class="msg_unread core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="unread">Unread</a><a class="msg_flag core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="flag">Flag</a><a class="msg_unflag core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="unflag">Unflag</a><a class="msg_delete core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="delete">Delete</a><a class="msg_archive core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="archive">Archive</a><a class="msg_junk core_msg_control btn btn-sm btn-light no_mobile border text-black-50" href="#" data-action="junk">Junk</a>foo</div>', message_controls($mod));
111111
}
112112
/**
113113
* @preserveGlobalState disabled

0 commit comments

Comments
 (0)