Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Fix PHPUnit 12 deprecations #567

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions tests/php/Store/SessionStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use SilverStripe\Dev\SapphireTest;
use SilverStripe\MFA\Store\SessionStore;
use SilverStripe\ORM\Connect\Database;
use SilverStripe\ORM\Connect\MySQLDatabase;
use SilverStripe\ORM\DB;
use SilverStripe\Security\Member;

Expand Down Expand Up @@ -78,18 +79,26 @@ public function testDatabaseIsNotAccessedOnDeserialise()

// Replace the DB connection with a mock
$connection = DB::get_conn();
$database = $this->getMockBuilder(Database::class)
->enableProxyingToOriginalMethods()
->setProxyTarget($connection)
->getMock();

$database->expects($this->never())->method('query');
$database->expects($this->never())->method('preparedQuery');
DB::set_conn($database);
$mock = new class ($connection) extends MySQLDatabase {
public int $queryNum = 0;
public int $preparedQueryNum = 0;
public function query($sql, $errorLevel = E_USER_ERROR)
{
$this->queryNum++;
}
public function preparedQuery($sql, $parameters, $errorLevel = E_USER_ERROR)
{
$this->preparedQueryNum++;
}
};
DB::set_conn($mock);

// Replicate the deserialisation that happens on session start
$store->__unserialize($serialised);

$this->assertSame(0, $mock->queryNum);
$this->assertSame(0, $mock->preparedQueryNum);

// Finish the test and allow mock assertions to fail the test
DB::set_conn($connection);
}
Expand Down
Loading