Skip to content

Commit

Permalink
Additional section tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bastianallgeier committed Apr 9, 2019
1 parent 3c66e36 commit 01ef12c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions tests/Cms/Sections/SectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ public function setUp(): void
]);
}

public function testMissingModel()
{
Section::$types = [
'test' => []
];

$this->expectException('Kirby\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Undefined section model');

$section = new Section('test', []);
}

public function testPropsDefaults()
{
Section::$types = [
Expand All @@ -40,4 +52,38 @@ public function testPropsDefaults()
$this->assertEquals('default', $section->example());
$this->assertEquals(['one', 'two'], $section->buttons());
}

public function testToResponse()
{
Section::$types = [
'test' => [
'props' => [
'a' => function ($a) {
return $a;
},
'a' => function ($b) {
return $b;
},
]
]
];

$section = new Section('test', [
'model' => new Page(['slug' => 'test']),
'a' => 'A',
'b' => 'B'
]);


$expected = [
'status' => 'ok',
'code' => 200,
'name' => 'test',
'type' => 'test',
'a' => 'A',
'b' => 'B'
];

$this->assertEquals($expected, $section->toResponse());
}
}

0 comments on commit 01ef12c

Please sign in to comment.