Skip to content

Commit

Permalink
Don't use singleton for getForm
Browse files Browse the repository at this point in the history
When using Injector to create a singleton constructor arguments are
ignored. This causes getForm to fail as SAMLLoginForm requires
constructor arguments.
  • Loading branch information
blueo authored and satrun77 committed Feb 12, 2024
1 parent 9342da8 commit 3f211b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Control/SAMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,6 @@ public function getLogger()
*/
public function getForm()
{
return Injector::inst()->get(SAMLLoginForm::class, true, [$this, SAMLAuthenticator::class, 'LoginForm']);
return Injector::inst()->get(SAMLLoginForm::class, false, [$this, SAMLAuthenticator::class, 'LoginForm']);
}
}
18 changes: 18 additions & 0 deletions tests/php/Control/SAMLControllerTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace SilverStripe\SAML\Tests\Control;

use SilverStripe\Dev\SapphireTest;
use SilverStripe\SAML\Control\SAMLController;

class SAMLControllerTest extends SapphireTest
{
public function testGetForm(): void
{
$controller = new SAMLController();

$form = $controller->getForm();

$this->assertNotNull($form);
}
}

0 comments on commit 3f211b5

Please sign in to comment.