PHPUnit 10 (and other bumps)

This commit is contained in:
Shish 2023-12-14 00:14:24 +00:00 committed by Shish
parent 5897bfdb7b
commit e114057dfe
15 changed files with 441 additions and 473 deletions

View file

@ -60,10 +60,10 @@
}, },
"require-dev" : { "require-dev" : {
"phpunit/phpunit" : "^9.0", "phpunit/phpunit" : "10.5.3",
"friendsofphp/php-cs-fixer" : "^3.12", "friendsofphp/php-cs-fixer" : "3.41.1",
"scrutinizer/ocular": "dev-master", "scrutinizer/ocular": "1.9",
"phpstan/phpstan": "1.10.x-dev" "phpstan/phpstan": "1.10.50"
}, },
"suggest": { "suggest": {
"ext-memcache": "memcache caching", "ext-memcache": "memcache caching",

801
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -6,7 +6,7 @@ namespace Shimmie2;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
class TestInit extends TestCase class InitTest extends TestCase
{ {
public function testInitExt() public function testInitExt()
{ {

View file

@ -49,7 +49,7 @@ class ImageBanTest extends ShimmiePHPUnitTestCase
$this->assertEquals(200, $page->code); $this->assertEquals(200, $page->code);
} }
public function onNotSuccessfulTest(\Throwable $t): void public function onNotSuccessfulTest(\Throwable $t): never
{ {
send_event(new RemoveImageHashBanEvent($this->hash)); send_event(new RemoveImageHashBanEvent($this->hash));
parent::onNotSuccessfulTest($t); // TODO: Change the autogenerated stub parent::onNotSuccessfulTest($t); // TODO: Change the autogenerated stub

View file

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Shimmie2; namespace Shimmie2;
use PHPUnit\Framework\Attributes\Depends;
class IndexTest extends ShimmiePHPUnitTestCase class IndexTest extends ShimmiePHPUnitTestCase
{ {
public function testIndexPage() public function testIndexPage()
@ -79,21 +81,21 @@ class IndexTest extends ShimmiePHPUnitTestCase
/* * * * * * * * * * * /* * * * * * * * * * *
* Tag Search * * Tag Search *
* * * * * * * * * * */ * * * * * * * * * * */
/** @depends testUpload */ #[Depends('testUpload')]
public function testTagSearchNoResults($image_ids) public function testTagSearchNoResults($image_ids)
{ {
$this->testUpload(); $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(); $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(); $image_ids = $this->testUpload();
@ -103,7 +105,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
/* * * * * * * * * * * /* * * * * * * * * * *
* Multi-Tag Search * * Multi-Tag Search *
* * * * * * * * * * */ * * * * * * * * * * */
/** @depends testUpload */ #[Depends('testUpload')]
public function testMultiTagSearchNoResults($image_ids) public function testMultiTagSearchNoResults($image_ids)
{ {
$this->testUpload(); $this->testUpload();
@ -112,14 +114,14 @@ class IndexTest extends ShimmiePHPUnitTestCase
$this->assert_search_results(["computer", "asdfasdfwaffle"], []); $this->assert_search_results(["computer", "asdfasdfwaffle"], []);
} }
/** @depends testUpload */ #[Depends('testUpload')]
public function testMultiTagSearchOneResult($image_ids) public function testMultiTagSearchOneResult($image_ids)
{ {
$image_ids = $this->testUpload(); $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(); $image_ids = $this->testUpload();
@ -129,7 +131,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
/* * * * * * * * * * * /* * * * * * * * * * *
* Meta Search * * Meta Search *
* * * * * * * * * * */ * * * * * * * * * * */
/** @depends testUpload */ #[Depends('testUpload')]
public function testMetaSearchNoResults($image_ids) public function testMetaSearchNoResults($image_ids)
{ {
$this->testUpload(); $this->testUpload();
@ -137,7 +139,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
$this->assert_search_results(["ratio=42:12345"], []); $this->assert_search_results(["ratio=42:12345"], []);
} }
/** @depends testUpload */ #[Depends('testUpload')]
public function testMetaSearchOneResult($image_ids) public function testMetaSearchOneResult($image_ids)
{ {
$image_ids = $this->testUpload(); $image_ids = $this->testUpload();
@ -147,7 +149,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
$this->assert_search_results(["filename=screenshot"], [$image_ids[0]]); $this->assert_search_results(["filename=screenshot"], [$image_ids[0]]);
} }
/** @depends testUpload */ #[Depends('testUpload')]
public function testMetaSearchManyResults($image_ids) public function testMetaSearchManyResults($image_ids)
{ {
$image_ids = $this->testUpload(); $image_ids = $this->testUpload();
@ -159,14 +161,14 @@ class IndexTest extends ShimmiePHPUnitTestCase
/* * * * * * * * * * * /* * * * * * * * * * *
* Wildcards * * Wildcards *
* * * * * * * * * * */ * * * * * * * * * * */
/** @depends testUpload */ #[Depends('testUpload')]
public function testWildSearchNoResults($image_ids) public function testWildSearchNoResults($image_ids)
{ {
$this->testUpload(); $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(); $image_ids = $this->testUpload();
@ -175,7 +177,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
$this->assert_search_results(["comp*", "screenshot"], [$image_ids[0]]); $this->assert_search_results(["comp*", "screenshot"], [$image_ids[0]]);
} }
/** @depends testUpload */ #[Depends('testUpload')]
public function testWildSearchManyResults($image_ids) public function testWildSearchManyResults($image_ids)
{ {
$image_ids = $this->testUpload(); $image_ids = $this->testUpload();
@ -187,7 +189,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
/* * * * * * * * * * * /* * * * * * * * * * *
* Mixed * * Mixed *
* * * * * * * * * * */ * * * * * * * * * * */
/** @depends testUpload */ #[Depends('testUpload')]
public function testMixedSearchTagMeta($image_ids) public function testMixedSearchTagMeta($image_ids)
{ {
$image_ids = $this->testUpload(); $image_ids = $this->testUpload();
@ -200,7 +202,7 @@ class IndexTest extends ShimmiePHPUnitTestCase
/* * * * * * * * * * * /* * * * * * * * * * *
* Negative * * Negative *
* * * * * * * * * * */ * * * * * * * * * * */
/** @depends testUpload */ #[Depends('testUpload')]
public function testNegative($image_ids) public function testNegative($image_ids)
{ {
$image_ids = $this->testUpload(); $image_ids = $this->testUpload();

View file

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Shimmie2; namespace Shimmie2;
use PHPUnit\Framework\Attributes\Depends;
class PoolsTest extends ShimmiePHPUnitTestCase class PoolsTest extends ShimmiePHPUnitTestCase
{ {
public function setUp(): void public function setUp(): void
@ -50,7 +52,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
return [$pool_id, [$image_id_1, $image_id_2]]; return [$pool_id, [$image_id_1, $image_id_2]];
} }
/** @depends testCreate */ #[Depends('testCreate')]
public function testOnViewImage($args) public function testOnViewImage($args)
{ {
[$pool_id, $image_ids] = $this->testCreate(); [$pool_id, $image_ids] = $this->testCreate();
@ -64,7 +66,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
$this->assert_text("Pool"); $this->assert_text("Pool");
} }
/** @depends testCreate */ #[Depends('testCreate')]
public function testSearch($args) public function testSearch($args)
{ {
[$pool_id, $image_ids] = $this->testCreate(); [$pool_id, $image_ids] = $this->testCreate();
@ -76,7 +78,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
$this->assert_text("Pool"); $this->assert_text("Pool");
} }
/** @depends testCreate */ #[Depends('testCreate')]
public function testList($args) public function testList($args)
{ {
$this->testCreate(); $this->testCreate();
@ -84,7 +86,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
$this->assert_text("Pool"); $this->assert_text("Pool");
} }
/** @depends testCreate */ #[Depends('testCreate')]
public function testView($args) public function testView($args)
{ {
[$pool_id, $image_ids] = $this->testCreate(); [$pool_id, $image_ids] = $this->testCreate();
@ -93,7 +95,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
$this->assert_text("Pool"); $this->assert_text("Pool");
} }
/** @depends testCreate */ #[Depends('testCreate')]
public function testHistory($args) public function testHistory($args)
{ {
[$pool_id, $image_ids] = $this->testCreate(); [$pool_id, $image_ids] = $this->testCreate();
@ -102,7 +104,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
$this->assert_text("Pool"); $this->assert_text("Pool");
} }
/** @depends testCreate */ #[Depends('testCreate')]
public function testImport($args) public function testImport($args)
{ {
[$pool_id, $image_ids] = $this->testCreate(); [$pool_id, $image_ids] = $this->testCreate();
@ -114,7 +116,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
$this->assert_text("Pool"); $this->assert_text("Pool");
} }
/** @depends testCreate */ #[Depends('testCreate')]
public function testRemovePosts($args): array public function testRemovePosts($args): array
{ {
[$pool_id, $image_ids] = $this->testCreate(); [$pool_id, $image_ids] = $this->testCreate();
@ -128,7 +130,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
return [$pool_id, $image_ids]; return [$pool_id, $image_ids];
} }
/** @depends testRemovePosts */ #[Depends('testRemovePosts')]
public function testAddPosts($args) public function testAddPosts($args)
{ {
[$pool_id, $image_ids] = $this->testRemovePosts(null); [$pool_id, $image_ids] = $this->testRemovePosts(null);
@ -140,7 +142,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase
$this->assertEquals(PageMode::REDIRECT, $page->mode); $this->assertEquals(PageMode::REDIRECT, $page->mode);
} }
/** @depends testCreate */ #[Depends('testCreate')]
public function testEditDescription($args): array public function testEditDescription($args): array
{ {
[$pool_id, $image_ids] = $this->testCreate(); [$pool_id, $image_ids] = $this->testCreate();

View file

@ -4,6 +4,8 @@ declare(strict_types=1);
namespace Shimmie2; namespace Shimmie2;
use PHPUnit\Framework\Attributes\Depends;
class RelationshipsTest extends ShimmiePHPUnitTestCase class RelationshipsTest extends ShimmiePHPUnitTestCase
{ {
//================================================================= //=================================================================
@ -32,9 +34,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
return [$image_1, $image_2, $image_3]; return [$image_1, $image_2, $image_3];
} }
/** #[Depends('testNoParent')]
* @depends testNoParent
*/
public function testSetParent($imgs): array public function testSetParent($imgs): array
{ {
[$image_1, $image_2, $image_3] = $this->testNoParent(); [$image_1, $image_2, $image_3] = $this->testNoParent();
@ -56,9 +56,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
return [$image_1, $image_2, $image_3]; return [$image_1, $image_2, $image_3];
} }
/** #[Depends('testSetParent')]
* @depends testSetParent
*/
public function testChangeParent($imgs): array public function testChangeParent($imgs): array
{ {
[$image_1, $image_2, $image_3] = $this->testSetParent(null); [$image_1, $image_2, $image_3] = $this->testSetParent(null);
@ -79,9 +77,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
return [$image_1, $image_2, $image_3]; return [$image_1, $image_2, $image_3];
} }
/** #[Depends('testSetParent')]
* @depends testSetParent
*/
public function testSearch($imgs) public function testSearch($imgs)
{ {
[$image_1, $image_2, $image_3] = $this->testSetParent(null); [$image_1, $image_2, $image_3] = $this->testSetParent(null);
@ -94,9 +90,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
$this->assert_search_results(["child:none"], [$image_3->id, $image_2->id]); $this->assert_search_results(["child:none"], [$image_3->id, $image_2->id]);
} }
/** #[Depends('testChangeParent')]
* @depends testChangeParent
*/
public function testRemoveParent($imgs) public function testRemoveParent($imgs)
{ {
[$image_1, $image_2, $image_3] = $this->testChangeParent(null); [$image_1, $image_2, $image_3] = $this->testChangeParent(null);
@ -146,9 +140,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
return [$image_1, $image_2, $image_3]; return [$image_1, $image_2, $image_3];
} }
/** #[Depends('testSetParentByTagBase')]
* @depends testSetParentByTagBase
*/
public function testSetParentByTag($imgs): array public function testSetParentByTag($imgs): array
{ {
[$image_1, $image_2, $image_3] = $this->testSetParentByTagBase(); [$image_1, $image_2, $image_3] = $this->testSetParentByTagBase();
@ -171,9 +163,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
return [$image_1, $image_2, $image_3]; return [$image_1, $image_2, $image_3];
} }
/** #[Depends('testSetParentByTag')]
* @depends testSetParentByTag
*/
public function testSetChildByTag($imgs): array public function testSetChildByTag($imgs): array
{ {
[$image_1, $image_2, $image_3] = $this->testSetParentByTag(null); [$image_1, $image_2, $image_3] = $this->testSetParentByTag(null);
@ -196,9 +186,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase
return [$image_1, $image_2, $image_3]; return [$image_1, $image_2, $image_3];
} }
/** #[Depends('testSetChildByTag')]
* @depends testSetChildByTag
*/
public function testRemoveParentByTag($imgs) public function testRemoveParentByTag($imgs)
{ {
[$image_1, $image_2, $image_3] = $this->testSetChildByTag(null); [$image_1, $image_2, $image_3] = $this->testSetChildByTag(null);

View file

@ -64,7 +64,7 @@ abstract class ShimmiePHPUnitTestCase extends TestCase
public function setUp(): void public function setUp(): void
{ {
global $database, $_tracer; global $database, $_tracer;
$_tracer->begin($this->getName()); $_tracer->begin($this->name());
$_tracer->begin("setUp"); $_tracer->begin("setUp");
$class = str_replace("Test", "", get_class($this)); $class = str_replace("Test", "", get_class($this));
if (!ExtensionInfo::get_for_extension_class($class)->is_supported()) { if (!ExtensionInfo::get_for_extension_class($class)->is_supported()) {

View file

@ -1,18 +1,19 @@
<?xml version="1.0"?> <?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"> <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="../tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd">
<coverage> <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>
</testsuite> </testsuite>
<testsuite name="ext"> <testsuite name="ext">
<directory suffix="test.php">../ext/</directory> <directory suffix="test.php">../ext/</directory>
</testsuite> </testsuite>
</testsuites> </testsuites>
<source>
<include>
<directory suffix=".php">../core</directory>
<directory suffix=".php">../ext</directory>
<directory suffix=".php">../themes/default</directory>
</include>
</source>
</phpunit> </phpunit>