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 mikenuguid committed Mar 19, 2024
1 parent 43fd2cb commit 74f68c6
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 @@ -348,6 +348,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 74f68c6

Please sign in to comment.