Skip to content

Commit

Permalink
MNT Move config from silverstripe/admin so that unit-tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Aug 14, 2024
1 parent 58efda3 commit c47a600
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
20 changes: 20 additions & 0 deletions tests/Middleware/CSRFMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,26 @@

class CSRFMiddlewareTest extends BaseMiddlewareProcessTest
{
private bool $securityTokenWasEnabled = false;

protected function setUp(): void
{
parent::setUp();
// CSRF token check is normally disabled for unit-tests
$this->securityTokenWasEnabled = SecurityToken::is_enabled();
if (!$this->securityTokenWasEnabled) {
SecurityToken::enable();
}
}

protected function tearDown(): void
{
parent::tearDown();
if (!$this->securityTokenWasEnabled) {
SecurityToken::disable();
}
}

public function testItDoesntDoAnythingIfNotAMutation()
{
$this->assertEquals('resolved', $this->simulateMiddlewareProcess(
Expand Down
5 changes: 4 additions & 1 deletion tests/Schema/TestSchemaBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SilverStripe\GraphQL\Schema\Logger;
use SilverStripe\GraphQL\Schema\Schema;
use SilverStripe\GraphQL\Schema\SchemaBuilder;
use SilverStripe\GraphQL\Schema\Services\SchemaTranscribeHandler;

class TestSchemaBuilder extends SchemaBuilder
{
Expand Down Expand Up @@ -101,7 +102,9 @@ private function bootstrapSchema(string $key)
'properties' => [
'handlers' => [
'graphqlTranscribe' => [
'off' => ['graphqlSchemaBuild']
'off' => ['graphqlSchemaBuild'],
'on' => ['graphqlSchemaBuild'],
'handler' => '%$' . SchemaTranscribeHandler::class,
],
],
],
Expand Down

0 comments on commit c47a600

Please sign in to comment.