Passed
Push — nested-vendor ( f8843a )
by Sam
09:43
created

testGetFormThrowsExceptionOnMissingContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\Forms\Tests;
4
5
use InvalidArgumentException;
6
use SilverStripe\Dev\SapphireTest;
7
use SilverStripe\Forms\DefaultFormFactory;
8
use SilverStripe\ORM\DataObject;
9
10
class DefaultFormFactoryTest extends SapphireTest
11
{
12
    /**
13
     * @expectedException InvalidArgumentException
14
     * @expectedExceptionMessageRegExp /Missing required context/
15
     */
16
    public function testGetFormThrowsExceptionOnMissingContext()
17
    {
18
        $factory = new DefaultFormFactory();
19
        $factory->getForm();
20
    }
21
22
    public function testGetForm()
23
    {
24
        $record = new DataObject();
25
        $record->Title = 'Test';
26
27
        $factory = new DefaultFormFactory();
28
        $form = $factory->getForm(null, null, ['Record' => $record]);
29
30
        $this->assertSame($record, $form->getRecord());
31
    }
32
33
    public function testGetRequiredContext()
34
    {
35
        $factory = new DefaultFormFactory();
36
        $this->assertContains('Record', $factory->getRequiredContext());
37
    }
38
}
39