phpunit9
This commit is contained in:
parent
4bf2cb8ee7
commit
69112fdee3
@ -77,18 +77,21 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testTagSearchNoResults($image_ids)
|
public function testTagSearchNoResults($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["maumaumau"], []);
|
$this->assert_search_results(["maumaumau"], []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testTagSearchOneResult($image_ids)
|
public function testTagSearchOneResult($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["pbx"], [$image_ids[0]]);
|
$this->assert_search_results(["pbx"], [$image_ids[0]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testTagSearchManyResults($image_ids)
|
public function testTagSearchManyResults($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["computer"], [$image_ids[1], $image_ids[0]]);
|
$this->assert_search_results(["computer"], [$image_ids[1], $image_ids[0]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +101,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testMultiTagSearchNoResults($image_ids)
|
public function testMultiTagSearchNoResults($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
# multiple tags, one of which doesn't exist
|
# multiple tags, one of which doesn't exist
|
||||||
# (test the "one tag doesn't exist = no hits" path)
|
# (test the "one tag doesn't exist = no hits" path)
|
||||||
$this->assert_search_results(["computer", "asdfasdfwaffle"], []);
|
$this->assert_search_results(["computer", "asdfasdfwaffle"], []);
|
||||||
@ -106,12 +110,14 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testMultiTagSearchOneResult($image_ids)
|
public function testMultiTagSearchOneResult($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["computer", "screenshot"], [$image_ids[0]]);
|
$this->assert_search_results(["computer", "screenshot"], [$image_ids[0]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testMultiTagSearchManyResults($image_ids)
|
public function testMultiTagSearchManyResults($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["computer", "thing"], [$image_ids[1], $image_ids[0]]);
|
$this->assert_search_results(["computer", "thing"], [$image_ids[1], $image_ids[0]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,12 +127,14 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testMetaSearchNoResults($image_ids)
|
public function testMetaSearchNoResults($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["hash=1234567890"], []);
|
$this->assert_search_results(["hash=1234567890"], []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testMetaSearchOneResult($image_ids)
|
public function testMetaSearchOneResult($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["hash=feb01bab5698a11dd87416724c7a89e3"], [$image_ids[0]]);
|
$this->assert_search_results(["hash=feb01bab5698a11dd87416724c7a89e3"], [$image_ids[0]]);
|
||||||
$this->assert_search_results(["md5=feb01bab5698a11dd87416724c7a89e3"], [$image_ids[0]]);
|
$this->assert_search_results(["md5=feb01bab5698a11dd87416724c7a89e3"], [$image_ids[0]]);
|
||||||
$this->assert_search_results(["id={$image_ids[1]}"], [$image_ids[1]]);
|
$this->assert_search_results(["id={$image_ids[1]}"], [$image_ids[1]]);
|
||||||
@ -136,6 +144,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testMetaSearchManyResults($image_ids)
|
public function testMetaSearchManyResults($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["size=640x480"], [$image_ids[1], $image_ids[0]]);
|
$this->assert_search_results(["size=640x480"], [$image_ids[1], $image_ids[0]]);
|
||||||
$this->assert_search_results(["tags=5"], [$image_ids[1], $image_ids[0]]);
|
$this->assert_search_results(["tags=5"], [$image_ids[1], $image_ids[0]]);
|
||||||
$this->assert_search_results(["ext=jpg"], [$image_ids[1], $image_ids[0]]);
|
$this->assert_search_results(["ext=jpg"], [$image_ids[1], $image_ids[0]]);
|
||||||
@ -147,12 +156,14 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testWildSearchNoResults($image_ids)
|
public function testWildSearchNoResults($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
$this->assert_search_results(["asdfasdf*"], []);
|
$this->assert_search_results(["asdfasdf*"], []);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testWildSearchOneResult($image_ids)
|
public function testWildSearchOneResult($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
// Only the first image matches both the wildcard and the tag.
|
// Only the first image matches both the wildcard and the tag.
|
||||||
// This checks for https://github.com/shish/shimmie2/issues/547
|
// This checks for https://github.com/shish/shimmie2/issues/547
|
||||||
$this->assert_search_results(["comp*", "screenshot"], [$image_ids[0]]);
|
$this->assert_search_results(["comp*", "screenshot"], [$image_ids[0]]);
|
||||||
@ -161,6 +172,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testWildSearchManyResults($image_ids)
|
public function testWildSearchManyResults($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
// two images match comp* - one matches it once,
|
// two images match comp* - one matches it once,
|
||||||
// one matches it twice
|
// one matches it twice
|
||||||
$this->assert_search_results(["comp*"], [$image_ids[1], $image_ids[0]]);
|
$this->assert_search_results(["comp*"], [$image_ids[1], $image_ids[0]]);
|
||||||
@ -172,6 +184,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testMixedSearchTagMeta($image_ids)
|
public function testMixedSearchTagMeta($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
// multiple tags, many results
|
// multiple tags, many results
|
||||||
$this->assert_search_results(["computer", "size=640x480"], [$image_ids[1], $image_ids[0]]);
|
$this->assert_search_results(["computer", "size=640x480"], [$image_ids[1], $image_ids[0]]);
|
||||||
}
|
}
|
||||||
@ -184,6 +197,8 @@ class IndexTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testUpload */
|
/** @depends testUpload */
|
||||||
public function testNegative($image_ids)
|
public function testNegative($image_ids)
|
||||||
{
|
{
|
||||||
|
$image_ids = $this->testUpload();
|
||||||
|
|
||||||
// negative tag, should have one result
|
// negative tag, should have one result
|
||||||
$this->assert_search_results(["computer", "-pbx"], [$image_ids[1]]);
|
$this->assert_search_results(["computer", "-pbx"], [$image_ids[1]]);
|
||||||
|
|
||||||
|
@ -58,6 +58,16 @@ class PoolCreationEvent extends Event
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class PoolDeletionEvent extends Event {
|
||||||
|
public $pool_id;
|
||||||
|
|
||||||
|
public function __construct(int $pool_id)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->pool_id = $pool_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class Pool
|
class Pool
|
||||||
{
|
{
|
||||||
public $id;
|
public $id;
|
||||||
@ -379,7 +389,7 @@ class Pools extends Extension
|
|||||||
// Completely remove the given pool.
|
// Completely remove the given pool.
|
||||||
// -> Only admins and owners may do this
|
// -> Only admins and owners may do this
|
||||||
if ($user->can(Permissions::POOLS_ADMIN) || $user->id == $pool->user_id) {
|
if ($user->can(Permissions::POOLS_ADMIN) || $user->id == $pool->user_id) {
|
||||||
$this->nuke_pool($pool_id);
|
send_event(new PoolDeletionEvent($pool_id));
|
||||||
$page->set_mode(PageMode::REDIRECT);
|
$page->set_mode(PageMode::REDIRECT);
|
||||||
$page->set_redirect(make_link("pool/list"));
|
$page->set_redirect(make_link("pool/list"));
|
||||||
} else {
|
} else {
|
||||||
@ -797,19 +807,16 @@ class Pools extends Extension
|
|||||||
/**
|
/**
|
||||||
* HERE WE NUKE ENTIRE POOL. WE REMOVE POOLS AND POSTS FROM REMOVED POOL AND HISTORIES ENTRIES FROM REMOVED POOL.
|
* HERE WE NUKE ENTIRE POOL. WE REMOVE POOLS AND POSTS FROM REMOVED POOL AND HISTORIES ENTRIES FROM REMOVED POOL.
|
||||||
*/
|
*/
|
||||||
private function nuke_pool(int $poolID)
|
public function onPoolDeletion(PoolDeletionEvent $event)
|
||||||
{
|
{
|
||||||
global $user, $database;
|
global $user, $database;
|
||||||
|
$poolID = $event->pool_id;
|
||||||
|
|
||||||
$p_id = (int)$database->get_one("SELECT user_id FROM pools WHERE id = :pid", ["pid" => $poolID]);
|
$owner_id = (int)$database->get_one("SELECT user_id FROM pools WHERE id = :pid", ["pid" => $poolID]);
|
||||||
if ($user->can(Permissions::POOLS_ADMIN)) {
|
if ($owner_id == $user->id || $user->can(Permissions::POOLS_ADMIN)) {
|
||||||
$database->execute("DELETE FROM pool_history WHERE pool_id = :pid", ["pid" => $poolID]);
|
$database->execute("DELETE FROM pool_history WHERE pool_id = :pid", ["pid" => $poolID]);
|
||||||
$database->execute("DELETE FROM pool_images WHERE pool_id = :pid", ["pid" => $poolID]);
|
$database->execute("DELETE FROM pool_images WHERE pool_id = :pid", ["pid" => $poolID]);
|
||||||
$database->execute("DELETE FROM pools WHERE id = :pid", ["pid" => $poolID]);
|
$database->execute("DELETE FROM pools WHERE id = :pid", ["pid" => $poolID]);
|
||||||
} elseif ($user->id == $p_id) {
|
|
||||||
$database->execute("DELETE FROM pool_history WHERE pool_id = :pid", ["pid" => $poolID]);
|
|
||||||
$database->execute("DELETE FROM pool_images WHERE pool_id = :pid", ["pid" => $poolID]);
|
|
||||||
$database->execute("DELETE FROM pools WHERE id = :pid AND user_id = :uid", ["pid" => $poolID, "uid" => $user->id]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,22 @@
|
|||||||
<?php declare(strict_types=1);
|
<?php declare(strict_types=1);
|
||||||
class PoolsTest extends ShimmiePHPUnitTestCase
|
class PoolsTest extends ShimmiePHPUnitTestCase
|
||||||
{
|
{
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
// Clean up any leftovers to create a fresh test env
|
||||||
|
$this->log_in_as_admin();
|
||||||
|
global $database;
|
||||||
|
foreach ($database->get_col("SELECT id FROM pools") as $pool_id) {
|
||||||
|
send_event(new PoolDeletionEvent((int)$pool_id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function testAnon()
|
public function testAnon()
|
||||||
{
|
{
|
||||||
|
$this->log_out();
|
||||||
|
|
||||||
$this->get_page('pool/list');
|
$this->get_page('pool/list');
|
||||||
$this->assert_title("Pools");
|
$this->assert_title("Pools");
|
||||||
|
|
||||||
@ -34,7 +48,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testCreate */
|
/** @depends testCreate */
|
||||||
public function testOnViewImage($args)
|
public function testOnViewImage($args)
|
||||||
{
|
{
|
||||||
[$pool_id, $image_ids] = $args;
|
[$pool_id, $image_ids] = $this->testCreate();
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
$config->set_bool(PoolsConfig::ADDER_ON_VIEW_IMAGE, true);
|
$config->set_bool(PoolsConfig::ADDER_ON_VIEW_IMAGE, true);
|
||||||
@ -48,7 +62,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testCreate */
|
/** @depends testCreate */
|
||||||
public function testSearch($args)
|
public function testSearch($args)
|
||||||
{
|
{
|
||||||
[$pool_id, $image_ids] = $args;
|
[$pool_id, $image_ids] = $this->testCreate();
|
||||||
|
|
||||||
$this->get_page("post/list/pool=$pool_id/1");
|
$this->get_page("post/list/pool=$pool_id/1");
|
||||||
$this->assert_text("Pool");
|
$this->assert_text("Pool");
|
||||||
@ -60,7 +74,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testCreate */
|
/** @depends testCreate */
|
||||||
public function testList($args)
|
public function testList($args)
|
||||||
{
|
{
|
||||||
[$pool_id, $image_ids] = $args;
|
[$pool_id, $image_ids] = $this->testCreate();
|
||||||
|
|
||||||
$this->get_page("pool/list");
|
$this->get_page("pool/list");
|
||||||
$this->assert_text("Pool");
|
$this->assert_text("Pool");
|
||||||
@ -69,7 +83,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testCreate */
|
/** @depends testCreate */
|
||||||
public function testView($args)
|
public function testView($args)
|
||||||
{
|
{
|
||||||
[$pool_id, $image_ids] = $args;
|
[$pool_id, $image_ids] = $this->testCreate();
|
||||||
|
|
||||||
$this->get_page("pool/view/$pool_id");
|
$this->get_page("pool/view/$pool_id");
|
||||||
$this->assert_text("Pool");
|
$this->assert_text("Pool");
|
||||||
@ -78,7 +92,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testCreate */
|
/** @depends testCreate */
|
||||||
public function testHistory($args)
|
public function testHistory($args)
|
||||||
{
|
{
|
||||||
[$pool_id, $image_ids] = $args;
|
[$pool_id, $image_ids] = $this->testCreate();
|
||||||
|
|
||||||
$this->get_page("pool/updated/$pool_id");
|
$this->get_page("pool/updated/$pool_id");
|
||||||
$this->assert_text("Pool");
|
$this->assert_text("Pool");
|
||||||
@ -87,7 +101,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testCreate */
|
/** @depends testCreate */
|
||||||
public function testImport($args)
|
public function testImport($args)
|
||||||
{
|
{
|
||||||
[$pool_id, $image_ids] = $args;
|
[$pool_id, $image_ids] = $this->testCreate();
|
||||||
|
|
||||||
$this->post_page("pool/import", [
|
$this->post_page("pool/import", [
|
||||||
"pool_id" => $pool_id,
|
"pool_id" => $pool_id,
|
||||||
@ -99,7 +113,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testCreate */
|
/** @depends testCreate */
|
||||||
public function testRemovePosts($args)
|
public function testRemovePosts($args)
|
||||||
{
|
{
|
||||||
[$pool_id, $image_ids] = $args;
|
[$pool_id, $image_ids] = $this->testCreate();
|
||||||
|
|
||||||
$page = $this->post_page("pool/remove_posts", [
|
$page = $this->post_page("pool/remove_posts", [
|
||||||
"pool_id" => $pool_id,
|
"pool_id" => $pool_id,
|
||||||
@ -107,13 +121,13 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
]);
|
]);
|
||||||
$this->assertEquals("redirect", $page->mode);
|
$this->assertEquals("redirect", $page->mode);
|
||||||
|
|
||||||
return $args;
|
return [$pool_id, $image_ids];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testRemovePosts */
|
/** @depends testRemovePosts */
|
||||||
public function testAddPosts($args)
|
public function testAddPosts($args)
|
||||||
{
|
{
|
||||||
[$pool_id, $image_ids] = $args;
|
[$pool_id, $image_ids] = $this->testRemovePosts(null);
|
||||||
|
|
||||||
$page = $this->post_page("pool/add_posts", [
|
$page = $this->post_page("pool/add_posts", [
|
||||||
"pool_id" => $pool_id,
|
"pool_id" => $pool_id,
|
||||||
@ -125,7 +139,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
/** @depends testCreate */
|
/** @depends testCreate */
|
||||||
public function testEditDescription($args)
|
public function testEditDescription($args)
|
||||||
{
|
{
|
||||||
[$pool_id, $image_ids] = $args;
|
[$pool_id, $image_ids] = $this->testCreate();
|
||||||
|
|
||||||
$page = $this->post_page("pool/edit_description", [
|
$page = $this->post_page("pool/edit_description", [
|
||||||
"pool_id" => $pool_id,
|
"pool_id" => $pool_id,
|
||||||
@ -133,7 +147,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
|
|||||||
]);
|
]);
|
||||||
$this->assertEquals("redirect", $page->mode);
|
$this->assertEquals("redirect", $page->mode);
|
||||||
|
|
||||||
return $args;
|
return [$pool_id, $image_ids];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testNuke()
|
public function testNuke()
|
||||||
|
@ -32,7 +32,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetParent($imgs)
|
public function testSetParent($imgs)
|
||||||
{
|
{
|
||||||
[$image_1, $image_2, $image_3] = $imgs;
|
[$image_1, $image_2, $image_3] = $this->testNoParent();
|
||||||
|
|
||||||
send_event(new ImageRelationshipSetEvent($image_2->id, $image_1->id));
|
send_event(new ImageRelationshipSetEvent($image_2->id, $image_1->id));
|
||||||
|
|
||||||
@ -56,7 +56,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
|
|||||||
*/
|
*/
|
||||||
public function testChangeParent($imgs)
|
public function testChangeParent($imgs)
|
||||||
{
|
{
|
||||||
[$image_1, $image_2, $image_3] = $imgs;
|
[$image_1, $image_2, $image_3] = $this->testSetParent(null);
|
||||||
send_event(new ImageRelationshipSetEvent($image_2->id, $image_3->id));
|
send_event(new ImageRelationshipSetEvent($image_2->id, $image_3->id));
|
||||||
|
|
||||||
// refresh data from database
|
// refresh data from database
|
||||||
@ -79,7 +79,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRemoveParent($imgs)
|
public function testRemoveParent($imgs)
|
||||||
{
|
{
|
||||||
[$image_1, $image_2, $image_3] = $imgs;
|
[$image_1, $image_2, $image_3] = $this->testChangeParent(null);
|
||||||
|
|
||||||
global $database;
|
global $database;
|
||||||
$database->execute(
|
$database->execute(
|
||||||
@ -131,7 +131,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetParentByTag($imgs)
|
public function testSetParentByTag($imgs)
|
||||||
{
|
{
|
||||||
[$image_1, $image_2, $image_3] = $imgs;
|
[$image_1, $image_2, $image_3] = $this->testSetParentByTagBase();
|
||||||
|
|
||||||
send_event(new TagSetEvent($image_2, ["pbx", "parent:{$image_1->id}"]));
|
send_event(new TagSetEvent($image_2, ["pbx", "parent:{$image_1->id}"]));
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
|
|||||||
*/
|
*/
|
||||||
public function testSetChildByTag($imgs)
|
public function testSetChildByTag($imgs)
|
||||||
{
|
{
|
||||||
[$image_1, $image_2, $image_3] = $imgs;
|
[$image_1, $image_2, $image_3] = $this->testSetParentByTag(null);
|
||||||
|
|
||||||
send_event(new TagSetEvent($image_3, ["pbx", "child:{$image_1->id}"]));
|
send_event(new TagSetEvent($image_3, ["pbx", "child:{$image_1->id}"]));
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
|
|||||||
*/
|
*/
|
||||||
public function testRemoveParentByTag($imgs)
|
public function testRemoveParentByTag($imgs)
|
||||||
{
|
{
|
||||||
[$image_1, $image_2, $image_3] = $imgs;
|
[$image_1, $image_2, $image_3] = $this->testSetChildByTag(null);
|
||||||
assert(!is_null($image_3));
|
assert(!is_null($image_3));
|
||||||
|
|
||||||
// check parent is set
|
// check parent is set
|
||||||
|
@ -66,26 +66,21 @@ abstract class ShimmiePHPUnitTestCase extends TestCase
|
|||||||
$this->markTestSkipped("$class not supported with this database");
|
$this->markTestSkipped("$class not supported with this database");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a parent test, don't wipe out the state they gave us
|
// Set up a clean environment for each test
|
||||||
if (!$this->getDependencyInput()) {
|
|
||||||
// things to do after bootstrap and before request
|
|
||||||
// log in as anon
|
|
||||||
self::log_out();
|
self::log_out();
|
||||||
|
|
||||||
foreach ($database->get_col("SELECT id FROM images") as $image_id) {
|
foreach ($database->get_col("SELECT id FROM images") as $image_id) {
|
||||||
send_event(new ImageDeletionEvent(Image::by_id((int)$image_id), true));
|
send_event(new ImageDeletionEvent(Image::by_id((int)$image_id), true));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$_tracer->end();
|
$_tracer->end(); # setUp
|
||||||
$_tracer->begin("test");
|
$_tracer->begin("test");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown(): void
|
public function tearDown(): void
|
||||||
{
|
{
|
||||||
global $_tracer;
|
global $_tracer;
|
||||||
$_tracer->end();
|
$_tracer->end(); # test
|
||||||
$_tracer->end();
|
$_tracer->end(); # $this->getName()
|
||||||
$_tracer->clear();
|
$_tracer->clear();
|
||||||
$_tracer->flush("tests/trace.json");
|
$_tracer->flush("tests/trace.json");
|
||||||
}
|
}
|
||||||
@ -94,7 +89,7 @@ abstract class ShimmiePHPUnitTestCase extends TestCase
|
|||||||
{
|
{
|
||||||
parent::tearDownAfterClass();
|
parent::tearDownAfterClass();
|
||||||
global $_tracer;
|
global $_tracer;
|
||||||
$_tracer->end();
|
$_tracer->end(); # get_called_class()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function create_user(string $name)
|
protected static function create_user(string $name)
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
<phpunit bootstrap="../tests/bootstrap.php" colors="true">
|
<?xml version="1.0"?>
|
||||||
|
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="../tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||||
|
<coverage>
|
||||||
|
<include>
|
||||||
|
<directory suffix=".php">../core</directory>
|
||||||
|
<directory suffix=".php">../ext</directory>
|
||||||
|
<directory suffix=".php">../themes/default</directory>
|
||||||
|
</include>
|
||||||
|
</coverage>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="core">
|
<testsuite name="core">
|
||||||
<directory suffix="test.php">../core/</directory>
|
<directory suffix="test.php">../core/</directory>
|
||||||
@ -7,11 +15,4 @@
|
|||||||
<directory suffix="test.php">../ext/</directory>
|
<directory suffix="test.php">../ext/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
<filter>
|
|
||||||
<whitelist>
|
|
||||||
<directory suffix=".php">../core</directory>
|
|
||||||
<directory suffix=".php">../ext</directory>
|
|
||||||
<directory suffix=".php">../themes/default</directory>
|
|
||||||
</whitelist>
|
|
||||||
</filter>
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user