PluginProbe
Responsive Menu – Create Mobile-Friendly Menu / 4.0.4
Responsive Menu – Create Mobile-Friendly Menu v4.0.4
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 / Management / OptionManagerTest.php

OptionManagerTest.php in Responsive Menu – Create Mobile-Friendly Menu 4.0.4, at tests/app/Management/OptionManagerTest.php

85 lines 2.4 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 use ResponsiveMenu\Management\OptionManager;
5 use ResponsiveMenu\Collections\OptionsCollection;
6
7 class OptionManagerTest extends TestCase {
8
9 private $db;
10 private $default_options = [
11 'foo' => 'bar',
12 'baz' => 'qux'
13 ];
14
15 public function setUp() {
16 $this->db = $this->createMock('ResponsiveMenu\Database\Database');
17 }
18
19 public function testUpdateOptionsReturnsCorrectly() {
20 $manager = new OptionManager($this->db, $this->default_options);
21 $to_update = ['foo' => 'new', 'moon' => 'rise'];
22
23 $updated = $manager->updateOptions($to_update);
24
25 $this->assertInstanceOf('ResponsiveMenu\Collections\OptionsCollection', $updated);
26
27 $expected = new OptionsCollection([
28 'foo' => 'new',
29 'baz' => 'qux',
30 'moon' => 'rise'
31 ]);
32
33 $this->assertEquals($expected, $updated);
34 }
35
36 public function testCreateOptionsReturnsCorrectly() {
37 $manager = new OptionManager($this->db, $this->default_options);
38 $to_create = ['moon' => 'rise'];
39
40 $updated = $manager->createOptions($to_create);
41
42 $this->assertInstanceOf('ResponsiveMenu\Collections\OptionsCollection', $updated);
43
44 $expected = new OptionsCollection([
45 'foo' => 'bar',
46 'baz' => 'qux',
47 'moon' => 'rise'
48 ]);
49
50 $this->assertEquals($expected, $updated);
51 }
52
53 public function testRemoveOptionsReturnsCorrectly() {
54 $manager = new OptionManager($this->db, $this->default_options);
55 $to_remove = ['foo' => 'new', 'moon' => 'rise'];
56
57 $updated = $manager->removeOptions($to_remove);
58
59 $this->assertInstanceOf('ResponsiveMenu\Collections\OptionsCollection', $updated);
60
61 $expected = new OptionsCollection([
62 'baz' => 'qux'
63 ]);
64
65 $this->assertEquals($expected, $updated);
66 }
67
68 public function testBuildFromArrayReturnsCorrectly() {
69 $manager = new OptionManager($this->db, $this->default_options);
70 $to_remove = ['foo' => 'new', 'moon' => 'rise'];
71
72 $updated = $manager->buildFromArray($to_remove);
73
74 $this->assertInstanceOf('ResponsiveMenu\Collections\OptionsCollection', $updated);
75
76 $expected = new OptionsCollection([
77 'foo' => 'new',
78 'baz' => 'qux',
79 'moon' => 'rise'
80 ]);
81
82 $this->assertEquals($expected, $updated);
83 }
84
85 }