PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 3.0.12
Responsive Menu – Create Mobile-Friendly Menu v3.0.12
4.7.3 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 All 90 releases
responsive-menu / tests / app / Factories / OptionFactoryTest.php

OptionFactoryTest.php in Responsive Menu – Create Mobile-Friendly Menu 3.0.12, at tests/app/Factories/OptionFactoryTest.php

62 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use PHPUnit\Framework\TestCase;
4
5 class OptionFactoryTest extends TestCase {
6
7 public static function setUpBeforeClass() {
8 if(!function_exists('stripslashes_deep')):
9 function stripslashes_deep($a) {
10 return $a;
11 }
12 endif;
13 }
14
15 public function setUp() {
16 $defaults = ['a' => 1, 'b' => 2, 'c' => 3];
17 $helpers = ['a' => ['filter' => 'ResponsiveMenu\Filters\HtmlFilter'], 'c' => ['filter' => 'ResponsiveMenu\Filters\JsonFilter']];
18 $this->factory = new ResponsiveMenu\Factories\OptionFactory($defaults, $helpers);
19 }
20
21 public function testSetFilterIsReturned() {
22 $option = $this->factory->build('a', 4);
23 $this->assertInstanceOf('ResponsiveMenu\Filters\HtmlFilter', $option->getFilter());
24 }
25
26 public function testDefaultFilterIsReturned() {
27 $option = $this->factory->build('b', 4);
28 $this->assertInstanceOf('ResponsiveMenu\Filters\TextFilter', $option->getFilter());
29 }
30
31 public function testOptionIsReturned() {
32 $option = $this->factory->build('b', 4);
33 $this->assertInstanceOf('ResponsiveMenu\Models\Option', $option);
34 }
35
36 public function testDefaultIsReturnedIfValueIsNull() {
37 $option = $this->factory->build('b', null);
38 $this->assertEquals(2, $option->getValue());
39 }
40
41 public function testZeroIsReturnedAndNotDefault() {
42 $option = $this->factory->build('b', 0);
43 $this->assertEquals(0, $option->getValue());
44 }
45
46 public function testUpdatedValueIsReturned() {
47 $option = $this->factory->build('a', 'updated');
48 $this->assertEquals('updated', $option->getValue());
49 }
50
51 public function testDecodingArrayData() {
52 $option = $this->factory->build('a', ['a' => 1, 'b' => ['a' => 1, 'b' => 2]]);
53 $this->assertEquals(['a' => 1, 'b' => ['a' => 1, 'b' => 2]], $option->getValue());
54 }
55
56 public function testDecodedOfJsonDataToArray() {
57 $option = $this->factory->build('c', '{"a":"1","b":"2"}');
58 $this->assertEquals('{"a":"1","b":"2"}', $option->getValue());
59 }
60
61 }
62