Skip to content

Commit 5f7f35f

Browse files
committed
add broken test
1 parent 862f597 commit 5f7f35f

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
use PHPUnit\Framework\TestCase;
4+
use UnityWebPortal\lib\UnityUser;
5+
use UnityWebPortal\lib\UnityLDAP;
6+
7+
class WorkerUpdateLDAPCacheTest extends TestCase
8+
{
9+
public function testFlushAndThenUpdate()
10+
{
11+
global $USER, $REDIS;
12+
switchUser(...getUserIsPIHasAtLeastOneMember());
13+
$initial_value = $USER->getPIGroup()->getGroupMemberUIDs(false);
14+
[$_, $output_lines] = executeWorker("update-ldap-cache.php", "-f");
15+
error_log(implode("\n", $output_lines));
16+
// switchUser(...getUserIsPIHasAtLeastOneMember()); // refresh $REDIS
17+
$after_flush_value = $REDIS->getCache($USER->getPIGroup()->gid, "members");
18+
$this->assertEqualsCanonicalizing([], $after_flush_value);
19+
[$_, $output_lines] = executeWorker("update-ldap-cache.php");
20+
error_log(implode("\n", $output_lines));
21+
// switchUser(...getUserIsPIHasAtLeastOneMember()); // refresh $REDIS
22+
$after_update_value = $REDIS->getCache($USER->getPIGroup()->gid, "members");
23+
$this->assertEqualsCanonicalizing($initial_value, $after_update_value);
24+
}
25+
}

test/phpunit-bootstrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function http_get(string $phpfile, array $get_data = []): void
163163
* @throws RuntimeException
164164
* @return [return code, output lines]
165165
*/
166-
function executeWorker(string $basename, string $args, bool $doThrowIfNonzero = true): array
166+
function executeWorker(string $basename, string $args = "", bool $doThrowIfNonzero = true): array
167167
{
168168
$command = sprintf("%s %s/../workers/%s %s 2>&1", PHP_BINARY, __DIR__, $basename, $args);
169169
$output = [];

0 commit comments

Comments
 (0)