Skip to content

Commit

Permalink
PHPUnit 10 (and other bumps)
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Dec 14, 2023
1 parent fd1bb21 commit 74669a3
Show file tree
Hide file tree
Showing 15 changed files with 441 additions and 473 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
},

"require-dev" : {
"phpunit/phpunit" : "^9.0",
"friendsofphp/php-cs-fixer" : "^3.12",
"scrutinizer/ocular": "dev-master",
"phpstan/phpstan": "1.10.x-dev"
"phpunit/phpunit" : "10.5.3",
"friendsofphp/php-cs-fixer" : "3.41.1",
"scrutinizer/ocular": "1.9",
"phpstan/phpstan": "1.10.50"
},
"suggest": {
"ext-memcache": "memcache caching",
Expand Down
801 changes: 388 additions & 413 deletions composer.lock

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion core/tests/init.test.php → core/tests/InitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use PHPUnit\Framework\TestCase;

class TestInit extends TestCase
class InitTest extends TestCase
{
public function testInitExt()
{
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion ext/image_hash_ban/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testBan()
$this->assertEquals(200, $page->code);
}

public function onNotSuccessfulTest(\Throwable $t): void
public function onNotSuccessfulTest(\Throwable $t): never
{
send_event(new RemoveImageHashBanEvent($this->hash));
parent::onNotSuccessfulTest($t); // TODO: Change the autogenerated stub
Expand Down
30 changes: 16 additions & 14 deletions ext/index/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Shimmie2;

use PHPUnit\Framework\Attributes\Depends;

class IndexTest extends ShimmiePHPUnitTestCase
{
public function testIndexPage()
Expand Down Expand Up @@ -79,21 +81,21 @@ public function testUpload(): array
/* * * * * * * * * * *
* Tag Search *
* * * * * * * * * * */
/** @depends testUpload */
#[Depends('testUpload')]
public function testTagSearchNoResults($image_ids)
{
$this->testUpload();
$this->assert_search_results(["maumaumau"], []);
}

/** @depends testUpload */
#[Depends('testUpload')]
public function testTagSearchOneResult($image_ids)
{
$image_ids = $this->testUpload();
$this->assert_search_results(["pbx"], [$image_ids[0]]);
}

/** @depends testUpload */
#[Depends('testUpload')]
public function testTagSearchManyResults($image_ids)
{
$image_ids = $this->testUpload();
Expand All @@ -103,7 +105,7 @@ public function testTagSearchManyResults($image_ids)
/* * * * * * * * * * *
* Multi-Tag Search *
* * * * * * * * * * */
/** @depends testUpload */
#[Depends('testUpload')]
public function testMultiTagSearchNoResults($image_ids)
{
$this->testUpload();
Expand All @@ -112,14 +114,14 @@ public function testMultiTagSearchNoResults($image_ids)
$this->assert_search_results(["computer", "asdfasdfwaffle"], []);
}

/** @depends testUpload */
#[Depends('testUpload')]
public function testMultiTagSearchOneResult($image_ids)
{
$image_ids = $this->testUpload();
$this->assert_search_results(["computer", "screenshot"], [$image_ids[0]]);
}

/** @depends testUpload */
#[Depends('testUpload')]
public function testMultiTagSearchManyResults($image_ids)
{
$image_ids = $this->testUpload();
Expand All @@ -129,15 +131,15 @@ public function testMultiTagSearchManyResults($image_ids)
/* * * * * * * * * * *
* Meta Search *
* * * * * * * * * * */
/** @depends testUpload */
#[Depends('testUpload')]
public function testMetaSearchNoResults($image_ids)
{
$this->testUpload();
$this->assert_search_results(["hash=1234567890"], []);
$this->assert_search_results(["ratio=42:12345"], []);
}

/** @depends testUpload */
#[Depends('testUpload')]
public function testMetaSearchOneResult($image_ids)
{
$image_ids = $this->testUpload();
Expand All @@ -147,7 +149,7 @@ public function testMetaSearchOneResult($image_ids)
$this->assert_search_results(["filename=screenshot"], [$image_ids[0]]);
}

/** @depends testUpload */
#[Depends('testUpload')]
public function testMetaSearchManyResults($image_ids)
{
$image_ids = $this->testUpload();
Expand All @@ -159,14 +161,14 @@ public function testMetaSearchManyResults($image_ids)
/* * * * * * * * * * *
* Wildcards *
* * * * * * * * * * */
/** @depends testUpload */
#[Depends('testUpload')]
public function testWildSearchNoResults($image_ids)
{
$this->testUpload();
$this->assert_search_results(["asdfasdf*"], []);
}

/** @depends testUpload */
#[Depends('testUpload')]
public function testWildSearchOneResult($image_ids)
{
$image_ids = $this->testUpload();
Expand All @@ -175,7 +177,7 @@ public function testWildSearchOneResult($image_ids)
$this->assert_search_results(["comp*", "screenshot"], [$image_ids[0]]);
}

/** @depends testUpload */
#[Depends('testUpload')]
public function testWildSearchManyResults($image_ids)
{
$image_ids = $this->testUpload();
Expand All @@ -187,7 +189,7 @@ public function testWildSearchManyResults($image_ids)
/* * * * * * * * * * *
* Mixed *
* * * * * * * * * * */
/** @depends testUpload */
#[Depends('testUpload')]
public function testMixedSearchTagMeta($image_ids)
{
$image_ids = $this->testUpload();
Expand All @@ -200,7 +202,7 @@ public function testMixedSearchTagMeta($image_ids)
/* * * * * * * * * * *
* Negative *
* * * * * * * * * * */
/** @depends testUpload */
#[Depends('testUpload')]
public function testNegative($image_ids)
{
$image_ids = $this->testUpload();
Expand Down
20 changes: 11 additions & 9 deletions ext/pools/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Shimmie2;

use PHPUnit\Framework\Attributes\Depends;

class PoolsTest extends ShimmiePHPUnitTestCase
{
public function setUp(): void
Expand Down Expand Up @@ -50,7 +52,7 @@ public function testCreate(): array
return [$pool_id, [$image_id_1, $image_id_2]];
}

/** @depends testCreate */
#[Depends('testCreate')]
public function testOnViewImage($args)
{
[$pool_id, $image_ids] = $this->testCreate();
Expand All @@ -64,7 +66,7 @@ public function testOnViewImage($args)
$this->assert_text("Pool");
}

/** @depends testCreate */
#[Depends('testCreate')]
public function testSearch($args)
{
[$pool_id, $image_ids] = $this->testCreate();
Expand All @@ -76,15 +78,15 @@ public function testSearch($args)
$this->assert_text("Pool");
}

/** @depends testCreate */
#[Depends('testCreate')]
public function testList($args)
{
$this->testCreate();
$this->get_page("pool/list");
$this->assert_text("Pool");
}

/** @depends testCreate */
#[Depends('testCreate')]
public function testView($args)
{
[$pool_id, $image_ids] = $this->testCreate();
Expand All @@ -93,7 +95,7 @@ public function testView($args)
$this->assert_text("Pool");
}

/** @depends testCreate */
#[Depends('testCreate')]
public function testHistory($args)
{
[$pool_id, $image_ids] = $this->testCreate();
Expand All @@ -102,7 +104,7 @@ public function testHistory($args)
$this->assert_text("Pool");
}

/** @depends testCreate */
#[Depends('testCreate')]
public function testImport($args)
{
[$pool_id, $image_ids] = $this->testCreate();
Expand All @@ -114,7 +116,7 @@ public function testImport($args)
$this->assert_text("Pool");
}

/** @depends testCreate */
#[Depends('testCreate')]
public function testRemovePosts($args): array
{
[$pool_id, $image_ids] = $this->testCreate();
Expand All @@ -128,7 +130,7 @@ public function testRemovePosts($args): array
return [$pool_id, $image_ids];
}

/** @depends testRemovePosts */
#[Depends('testRemovePosts')]
public function testAddPosts($args)
{
[$pool_id, $image_ids] = $this->testRemovePosts(null);
Expand All @@ -140,7 +142,7 @@ public function testAddPosts($args)
$this->assertEquals(PageMode::REDIRECT, $page->mode);
}

/** @depends testCreate */
#[Depends('testCreate')]
public function testEditDescription($args): array
{
[$pool_id, $image_ids] = $this->testCreate();
Expand Down
30 changes: 9 additions & 21 deletions ext/relationships/test.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Shimmie2;

use PHPUnit\Framework\Attributes\Depends;

class RelationshipsTest extends ShimmiePHPUnitTestCase
{
//=================================================================
Expand Down Expand Up @@ -32,9 +34,7 @@ public function testNoParent(): array
return [$image_1, $image_2, $image_3];
}

/**
* @depends testNoParent
*/
#[Depends('testNoParent')]
public function testSetParent($imgs): array
{
[$image_1, $image_2, $image_3] = $this->testNoParent();
Expand All @@ -56,9 +56,7 @@ public function testSetParent($imgs): array
return [$image_1, $image_2, $image_3];
}

/**
* @depends testSetParent
*/
#[Depends('testSetParent')]
public function testChangeParent($imgs): array
{
[$image_1, $image_2, $image_3] = $this->testSetParent(null);
Expand All @@ -79,9 +77,7 @@ public function testChangeParent($imgs): array
return [$image_1, $image_2, $image_3];
}

/**
* @depends testSetParent
*/
#[Depends('testSetParent')]
public function testSearch($imgs)
{
[$image_1, $image_2, $image_3] = $this->testSetParent(null);
Expand All @@ -94,9 +90,7 @@ public function testSearch($imgs)
$this->assert_search_results(["child:none"], [$image_3->id, $image_2->id]);
}

/**
* @depends testChangeParent
*/
#[Depends('testChangeParent')]
public function testRemoveParent($imgs)
{
[$image_1, $image_2, $image_3] = $this->testChangeParent(null);
Expand Down Expand Up @@ -146,9 +140,7 @@ public function testSetParentByTagBase(): array
return [$image_1, $image_2, $image_3];
}

/**
* @depends testSetParentByTagBase
*/
#[Depends('testSetParentByTagBase')]
public function testSetParentByTag($imgs): array
{
[$image_1, $image_2, $image_3] = $this->testSetParentByTagBase();
Expand All @@ -171,9 +163,7 @@ public function testSetParentByTag($imgs): array
return [$image_1, $image_2, $image_3];
}

/**
* @depends testSetParentByTag
*/
#[Depends('testSetParentByTag')]
public function testSetChildByTag($imgs): array
{
[$image_1, $image_2, $image_3] = $this->testSetParentByTag(null);
Expand All @@ -196,9 +186,7 @@ public function testSetChildByTag($imgs): array
return [$image_1, $image_2, $image_3];
}

/**
* @depends testSetChildByTag
*/
#[Depends('testSetChildByTag')]
public function testRemoveParentByTag($imgs)
{
[$image_1, $image_2, $image_3] = $this->testSetChildByTag(null);
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function setUpBeforeClass(): void
public function setUp(): void
{
global $database, $_tracer;
$_tracer->begin($this->getName());
$_tracer->begin($this->name());
$_tracer->begin("setUp");
$class = str_replace("Test", "", get_class($this));
if (!ExtensionInfo::get_for_extension_class($class)->is_supported()) {
Expand Down
19 changes: 10 additions & 9 deletions tests/phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?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>
<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/>
<testsuites>
<testsuite name="core">
<directory suffix="test.php">../core/</directory>
<directory suffix="Test.php">../core/</directory>
</testsuite>
<testsuite name="ext">
<directory suffix="test.php">../ext/</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">../core</directory>
<directory suffix=".php">../ext</directory>
<directory suffix=".php">../themes/default</directory>
</include>
</source>
</phpunit>

0 comments on commit 74669a3

Please sign in to comment.