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

API Stop using deprecated API #473

Merged
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
10 changes: 8 additions & 2 deletions tests/php/Store/SessionStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,21 @@
use SilverStripe\ORM\Connect\Database;
use SilverStripe\ORM\DB;
use SilverStripe\Security\Member;
use SilverStripe\Dev\Deprecation;

class SessionStoreTest extends SapphireTest
{
public function testSerializeThrowsExceptionOnFailure()
{
if (Deprecation::isEnabled()) {
$this->markTestSkipped('Test calls deprecated code');
}
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches('/possibly incorrectly encoded/');
$store = new SessionStore($this->createMock(Member::class));
$store->setState(['some binary' => random_bytes(32)]);
// changing this to __serialize() won't cause RunTimeException to
// be thrown because __serialize() does not use json_encode()
$store->serialize();
}

Expand Down Expand Up @@ -83,7 +89,7 @@ public function testDatabaseIsNotAccessedOnDeserialise()
$member = new Member();
$member->ID = 1;
$store = new SessionStore($member);
$serialised = $store->serialize();
$serialised = $store->__serialize();

// Replace the DB connection with a mock
$connection = DB::get_conn();
Expand All @@ -97,7 +103,7 @@ public function testDatabaseIsNotAccessedOnDeserialise()
DB::set_conn($database);

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

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