diff --git a/src/Forms/DefaultFormFactory.php b/src/Forms/DefaultFormFactory.php index 8aeaf3088..24c6e3feb 100644 --- a/src/Forms/DefaultFormFactory.php +++ b/src/Forms/DefaultFormFactory.php @@ -30,6 +30,7 @@ class DefaultFormFactory implements FormFactory * @param string $name * @param array $context * @return Form + * @throws InvalidArgumentException When required context is missing */ public function getForm(RequestHandler $controller = null, $name = FormFactory::DEFAULT_NAME, $context = []) { diff --git a/tests/php/Forms/DefaultFormFactoryTest.php b/tests/php/Forms/DefaultFormFactoryTest.php new file mode 100644 index 000000000..c8ab715f3 --- /dev/null +++ b/tests/php/Forms/DefaultFormFactoryTest.php @@ -0,0 +1,38 @@ +getForm(); + } + + public function testGetForm() + { + $record = new DataObject(); + $record->Title = 'Test'; + + $factory = new DefaultFormFactory(); + $form = $factory->getForm(null, null, ['Record' => $record]); + + $this->assertSame($record, $form->getRecord()); + } + + public function testGetRequiredContext() + { + $factory = new DefaultFormFactory(); + $this->assertContains('Record', $factory->getRequiredContext()); + } +}