Responsive Menu - Version 3.0.12

Version Description

(22nd September 2016) = ** Requires PHP 5.4** * Fixed close menu on link click bug with single header (Pro only) * Fixed conflict bug with "close on link clicks" and "disable parent click" options * Added header bar title link to WPML/Polylang * Added alt tag option for every image * Link target now taken into account with "Close Menu on Link Clicks"

Download this release

Release Info

Developer ResponsiveMenu
Plugin Icon 128x128 Responsive Menu
Version 3.0.12
Comparing to
See all releases

Code changes from version 3.0.11 to 3.0.12

Files changed (121) hide show
  1. readme.txt +60 -90
  2. responsive-menu.php +1 -1
  3. src/app/Collections/OptionsCollection.php +5 -5
  4. src/app/Mappers/JsMapper.php +6 -1
  5. src/app/Mappers/scss.inc.php +4 -4
  6. src/app/Walkers/WpWalker.php +7 -1
  7. src/config/admin_ordering.php +38 -0
  8. src/config/default_options.php +9 -2
  9. src/config/option_helpers.php +3 -0
  10. src/config/services.php +1 -1
  11. tests/app/Collections/OptionsCollectionTest.php +138 -0
  12. tests/app/Controllers/AdminTest.php +51 -0
  13. tests/app/Controllers/FrontTest.php +37 -0
  14. tests/app/Database/MigrationTest.php +114 -0
  15. tests/app/Database/WpDatabaseTest.php +61 -0
  16. tests/app/Factories/CssFactoryTest.php +35 -0
  17. tests/app/Factories/JsFactoryTest.php +30 -0
  18. tests/app/Factories/OptionFactoryTest.php +61 -0
  19. tests/app/Filesystem/FileCreatorTest.php +25 -0
  20. tests/app/Filesystem/FolderCreatorTest.php +21 -0
  21. tests/app/Filesystem/ScriptsBuilderTest.php +23 -0
  22. tests/app/Filters/HtmlFilterTest.php +15 -0
  23. tests/app/Filters/JsonFilterTest.php +19 -0
  24. tests/app/Filters/TextFilterTest.php +19 -0
  25. tests/app/Form/CheckboxTest.php +33 -0
  26. tests/app/Form/ColourTest.php +16 -0
  27. tests/app/Form/ExportTest.php +16 -0
  28. tests/app/Form/FontIconPageListTest.php +0 -0
  29. tests/app/Form/FontIconTest.php +23 -0
  30. tests/app/Form/HeaderBarOrderingTest.php +18 -0
  31. tests/app/Form/ImageTest.php +17 -0
  32. tests/app/Form/ImportTest.php +16 -0
  33. tests/app/Form/MenuOrderingTest.php +17 -0
  34. tests/app/Form/ResetTest.php +16 -0
  35. tests/app/Form/SelectTest.php +47 -0
  36. tests/app/Form/TextAreaTest.php +16 -0
  37. tests/app/Form/TextTest.php +16 -0
  38. tests/app/Formatters/MinifyTest.php +27 -0
  39. tests/app/Mappers/JsMapperTest.php +59 -0
  40. tests/app/Mappers/ScssBaseMapperTest.php +32 -0
  41. tests/app/Mappers/ScssButtonMapperTest.php +42 -0
  42. tests/app/Mappers/ScssMenuMapperTest.php +67 -0
  43. tests/app/Models/OptionTest.php +57 -0
  44. tests/app/Repositories/OptionRepositoryTest.php +87 -0
  45. tests/app/Routing/ContainerTest.php +66 -0
  46. tests/app/Services/OptionsServiceTest.php +59 -0
  47. tests/app/Translation/TranslatorTest.php +50 -0
  48. tests/app/View/AdminViewTest.php +19 -0
  49. tests/app/View/FrontViewTest.php +18 -0
  50. tests/app/ViewModels/ButtonTest.php +18 -0
  51. tests/app/ViewModels/Components/Admin/BoxesTest.php +50 -0
  52. tests/app/ViewModels/Components/Admin/TabsTest.php +25 -0
  53. tests/app/ViewModels/Components/Button/ButtonTest.php +36 -0
  54. tests/app/ViewModels/Components/ComponentFactoryTest.php +27 -0
  55. tests/app/ViewModels/Components/Menu/AdditionalContentTest.php +28 -0
  56. tests/app/ViewModels/Components/Menu/MenuTest.php +36 -0
  57. tests/app/ViewModels/Components/Menu/SearchTest.php +21 -0
  58. tests/app/ViewModels/Components/Menu/TitleTest.php +32 -0
  59. tests/app/ViewModels/MenuTest.php +32 -0
  60. tests/app/Walkers/WpWalkerTest.php +93 -0
  61. tests/scssc/ApiTest.php +80 -0
  62. tests/scssc/InputTest.php +80 -0
  63. tests/scssc/compare-scss.sh +25 -0
  64. tests/scssc/inputs/builtins.scss +171 -0
  65. tests/scssc/inputs/comments.scss +28 -0
  66. tests/scssc/inputs/compass_extract.scss +248 -0
  67. tests/scssc/inputs/content.scss +61 -0
  68. tests/scssc/inputs/content_with_function.scss +17 -0
  69. tests/scssc/inputs/default_args.scss +15 -0
  70. tests/scssc/inputs/directives.scss +108 -0
  71. tests/scssc/inputs/extends.scss +184 -0
  72. tests/scssc/inputs/filter_effects.scss +48 -0
  73. tests/scssc/inputs/functions.scss +81 -0
  74. tests/scssc/inputs/ie7.scss +12 -0
  75. tests/scssc/inputs/if.scss +76 -0
  76. tests/scssc/inputs/if_on_null.scss +8 -0
  77. tests/scssc/inputs/import.scss +23 -0
  78. tests/scssc/inputs/imports/_partial.scss +10 -0
  79. tests/scssc/inputs/imports/simple.scss +4 -0
  80. tests/scssc/inputs/interpolation.scss +86 -0
  81. tests/scssc/inputs/keyword_args.scss +24 -0
  82. tests/scssc/inputs/list.scss +15 -0
  83. tests/scssc/inputs/looping.scss +51 -0
  84. tests/scssc/inputs/media.scss +208 -0
  85. tests/scssc/inputs/mixins.scss +158 -0
  86. tests/scssc/inputs/nesting.scss +45 -0
  87. tests/scssc/inputs/null.scss +41 -0
  88. tests/scssc/inputs/operators.scss +143 -0
  89. tests/scssc/inputs/placeholder_selector.scss +18 -0
  90. tests/scssc/inputs/scss_css.scss +986 -0
  91. tests/scssc/inputs/selectors.scss +187 -0
  92. tests/scssc/inputs/values.scss +43 -0
  93. tests/scssc/inputs/variables.scss +56 -0
  94. tests/scssc/outputs/builtins.css +126 -0
  95. tests/scssc/outputs/comments.css +19 -0
  96. tests/scssc/outputs/compass_extract.css +28 -0
  97. tests/scssc/outputs/content.css +29 -0
  98. tests/scssc/outputs/content_with_function.css +2 -0
  99. tests/scssc/outputs/default_args.css +3 -0
  100. tests/scssc/outputs/directives.css +77 -0
  101. tests/scssc/outputs/extends.css +87 -0
  102. tests/scssc/outputs/filter_effects.css +20 -0
  103. tests/scssc/outputs/functions.css +22 -0
  104. tests/scssc/outputs/ie7.css +8 -0
  105. tests/scssc/outputs/if.css +21 -0
  106. tests/scssc/outputs/if_on_null.css +2 -0
  107. tests/scssc/outputs/import.css +27 -0
  108. tests/scssc/outputs/interpolation.css +54 -0
  109. tests/scssc/outputs/keyword_args.css +6 -0
  110. tests/scssc/outputs/list.css +7 -0
  111. tests/scssc/outputs/looping.css +45 -0
  112. tests/scssc/outputs/media.css +103 -0
  113. tests/scssc/outputs/mixins.css +83 -0
  114. tests/scssc/outputs/nesting.css +22 -0
  115. tests/scssc/outputs/null.css +21 -0
  116. tests/scssc/outputs/operators.css +105 -0
  117. tests/scssc/outputs/placeholder_selector.css +7 -0
  118. tests/scssc/outputs/scss_css.css +741 -0
  119. tests/scssc/outputs/selectors.css +335 -0
  120. tests/scssc/outputs/values.css +34 -0
  121. tests/scssc/outputs/variables.css +24 -0
readme.txt CHANGED
@@ -4,111 +4,67 @@ Donate link: https://responsive.menu/donate
4
  Tags: responsive, menu, responsive menu, mobile menu, wordpress responsive menu, wp responsive menu, tablet menu, mobile, tablet, 3 lines, 3 line, three line, three lines
5
  Requires at least: 3.5.0
6
  Tested up to: 4.6
7
- Stable tag: 3.0.11
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
- This is a Highly Customisable Responsive Menu Plugin for WordPress
12
 
13
  == Description ==
14
-
15
- This is a Highly Customisable Responsive Menu Plugin for WordPress, with over 120 customisable options giving you a combination of 14,000 options!
16
  <br /><br />
17
- **Requires PHP 5.4+**, please ensure you have this installed before upgrading.
18
  <br /><br />
19
- With this plugin, you can edit the following and more:
20
- <ul>
21
- <li>Menu Title</li>
22
- <li>Menu Title Image</li>
23
- <li>Button Title</li>
24
- <li>Button Title Image</li>
25
- <li>Menu To Responsify</li>
26
- <li>Media Query Breakpoint Width</li>
27
- <li>CSS Options For Hiding Specific Elements</li>
28
- <li>Menu Depth To Display</li>
29
- <li>Top Location</li>
30
- <li>Right Percentage Location</li>
31
- <li>Line & Text Colour</li>
32
- <li>Menu Button Background Colour</li>
33
- <li>Absolute and Fixed Positioning</li>
34
- <li>Menu Font</li>
35
- <li>Menu Title Colour</li>
36
- <li>Menu Title Hover Colour</li>
37
- <li>Menu Title Background Colour</li>
38
- <li>Menu Text Colour</li>
39
- <li>Menu Text Hover Colour</li>
40
- <li>Menu Background Colour</li>
41
- <li>Menu Link Background Hover Colour</li>
42
- <li>Menu Text Size</li>
43
- <li>Menu Button Text Size</li>
44
- <li>Menu Links Text Size</li>
45
- <li>Choose Overlay or Push Animations</li>
46
- <li>Slide Animation Speed</li>
47
- <li>Ability to auto expand/hide sub-menus</li>
48
- <li>Inclusion/Exclusion of Search Box</li>
49
- <li>Choice of Positioning of Search Box</li>
50
- <li>Transition speed</li>
51
- <li>Slide Animation Speed</li>
52
- <li>Menu Link Heights</li>
53
- <li>Text Alignment</li>
54
- <li>Choice of side to slide in from (left, right, top, bottom)</li>
55
- <li>Choice to use inline/external stylesheets and scripts</li>
56
- <li>Option to include JavaScript in footer</li>
57
- <li>Option to remove CSS !important tags</li>
58
- <li>Choice to Minify created CSS and JS files (saves up to 50% file space)</li>
59
- <li>Choice to auto-close menu items on click (for single page sites)</li>
60
- <li>Choice to replace 3 lines with an x on click</li>
61
- <li>Minimum width of menu</li>
62
- <li>Maximum width of menu</li>
63
- <li>Choice to Auto Expand Parent Links</li>
64
- <li>Choice to Ignore Clicks on Ancestor Links</li>
65
- <li>Choice to Close Menu Automatically on Page Clicks</li>
66
- <li>Choice to Specify Title Menu Link</li>
67
- <li>Choice to Specify Title Menu Link Location</li>
68
- <li>Ability to add custom HTML snippet inside the menu</li>
69
- <li>Choice of location for custom HTML snippet inside the menu</li>
70
- <li>Choice of using shortode or not</li>
71
- <li>Ability to change the 3 lines height</li>
72
- <li>Ability to change the 3 lines width</li>
73
- <li>Ability to Export Options</li>
74
- <li>Ability to Import Options</li>
75
- <li>Ability to set sub menu arrow shape/image Options</li>
76
- <li>Ability to set custom click trigger</li>
77
- <li>Ability to push menu button with animation</li>
78
- <li>Ability to change Current Page background hover colour</li>
79
- <li>Ability to change Current Page Link hover colour</li>
80
- <li>Ability to provide a custom walker option</li>
81
- <li>Ability to choose to use transient caching or not</li>
82
- <li>Ability to choose if menu is shown on left or right of screen</li>
83
- <li>Ability to set theme location menu</li>
84
- <li>Ability to reset to default</li>
85
- <li>Ability to set menu text location</li>
86
- <li>Ability to set menu text line height</li>
87
- <li>Plus more...</li>
88
- </ul>
89
- The plugin creates a nice three-lined mobile menu button (or custom image if you choose) that users can click on to bring a slide out menu (from the left, right, top or bottom - again your choice), which is easily navigated.
90
  <br /><br />
91
- It is fully responsive if you have the viewport meta tag on your site, using media queries with the widths defined by you. It can be used as a responsive menu, mobile menu, tablet menu or full dedicated menu for your main site.
92
  <br /><br />
93
- It requires no shortcodes (although you can use them) or fancy php code to be inserted by yourself making it very easy to install and you can design it to look exactly as you want to or leave it with its default values to have it looking amazing in just a matter of seconds.
94
  <br /><br />
95
- You have the choice to include the stylesheets and scripts inline to avoid adding any extra HTTP requests to your site or through external stylesheets created by the plug-in. Either way, the code added is extremely small (only a little jQuery and CSS) and there is even an option to minify the output if you wish saving a further 50% on file space.
96
  <br /><br />
97
- It also includes the following functionality:
 
 
 
 
98
  <ul>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  <li>WPML/Polylang Support</li>
 
 
100
  </ul>
101
- If you decide to go Pro then you will also get the following functionality:
 
102
  <ul>
 
 
103
  <li>FontIcon Support for individual menu items</li>
104
- <li>Button Animation Effects</li>
105
- <li>Colour Opacity option</li>
106
- <li>Header Bar</li>
107
- <li>Single Menu Option</li>
 
108
  </ul>
 
109
  For more reasons to go Pro, please visit <a target="_blank" href="https://responsive.menu/why-go-pro/">this page</a>.
110
- If you would like to see any other options added to the plugin or would like to help with translating the plugin into various languages then please email me or place them in a support ticket.
111
- <br />
112
 
113
  == Installation ==
114
 
@@ -138,14 +94,28 @@ To view our whole FAQ, please go to https://responsive.menu/faq/
138
 
139
  == Screenshots ==
140
 
141
- 1. Fully customisable Admin Screen
 
 
 
 
142
 
143
- 2. Example Front End Menu Button
144
 
145
- 3. Example Front End Expanded Menu
 
 
146
 
147
  == Changelog ==
148
 
 
 
 
 
 
 
 
 
149
  = 3.0.11 (29th August 2016) =
150
  ** Requires PHP 5.4**
151
  * Fixed export options bug (Pro only)
4
  Tags: responsive, menu, responsive menu, mobile menu, wordpress responsive menu, wp responsive menu, tablet menu, mobile, tablet, 3 lines, 3 line, three line, three lines
5
  Requires at least: 3.5.0
6
  Tested up to: 4.6
7
+ Stable tag: 3.0.12
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
11
+ Highly customisable Responsive Menu plugin with 150+ options. No coding knowledge needed to design it exactly as you want.
12
 
13
  == Description ==
14
+ **Description:**
 
15
  <br /><br />
16
+ Highly customisable Responsive Menu Plugin for WordPress. With over 150 customisable options you get a combination of 22,500 options! No coding experience or knowledge is needed with an easy to use interface you can get it looking exactly as you want with minimal fuss.
17
  <br /><br />
18
+ **See it in action:**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  <br /><br />
20
+ <a href="https://responsive.menu">https://responsive.menu</a>
21
  <br /><br />
22
+ **Requirements:**
23
  <br /><br />
24
+ PHP 5.4+
25
  <br /><br />
26
+ **Fully documented:**
27
+ <br /><br />
28
+ <a href="https://responsive.menu/docs/">https://responsive.menu/docs/</a>
29
+ <br /><br />
30
+ **Basic Functionality:**
31
  <ul>
32
+ <li>Change every colour</li>
33
+ <li>Set the fonts, font sizes and text alignment you want to use</li>
34
+ <li>Set which side and where you want the button to show</li>
35
+ <li>Set which side the menu appears from (left, right, top or bottom)</li>
36
+ <li>Choice of menu animations (slide over the top or push the content)</li>
37
+ <li>Choice of which Menu to use</li>
38
+ <li>Choice of screen size at which the menu will be shown</li>
39
+ <li>Choice of CSS elements to hide when menu is showing</li>
40
+ <li>Choice of Sub-menu depth to display down to</li>
41
+ <li>Choice of Animation Types & Speeds for the Menu & Button</li>
42
+ <li>Integrated search (fully customisable)</li>
43
+ <li>Ability to disable and re-order the different components</li>
44
+ <li>Ability to fix the button to the top or to let it scroll with the page</li>
45
+ <li>Ability to upload logos, sub-arrow images etc.</li>
46
+ <li>Ability to include Scripts externally, minified and in footer</li>
47
+ <li>Ability to import and export options in a click of a button</li>
48
+ <li>Ability to add custom HTML components</li>
49
+ <li>Ability to choose custom menu triggers</li>
50
  <li>WPML/Polylang Support</li>
51
+ <li>RTL Support</li>
52
+ <li>Plus much, much more!</li>
53
  </ul>
54
+
55
+ **Advanced & Pro Functionality:**
56
  <ul>
57
+ <li>Use background image for the menu</li>
58
+ <li>Preview your changes before implementing</li>
59
  <li>FontIcon Support for individual menu items</li>
60
+ <li>15 button animation effects</li>
61
+ <li>Colour opacity for all colours</li>
62
+ <li>Custom overlay colour and opacity</li>
63
+ <li>Integrated header bar</li>
64
+ <li>Let the plugin provide and style your main menu as well as hamburger menu</li>
65
  </ul>
66
+
67
  For more reasons to go Pro, please visit <a target="_blank" href="https://responsive.menu/why-go-pro/">this page</a>.
 
 
68
 
69
  == Installation ==
70
 
94
 
95
  == Screenshots ==
96
 
97
+ 1. Example Front End Menu Button
98
+
99
+ 2. Front End Expanded Menu with Background Image (requires Pro)
100
+
101
+ 3. Alternative Example Front End Expanded Menu with Background Image (requires Pro)
102
 
103
+ 4. Alternative Example Front End Expanded Menu with Background Image (requires Pro)
104
 
105
+ 5. Alternative Example Front End Expanded Menu with Background Image (requires Pro)
106
+
107
+ 6. Fully customisable Admin Screen
108
 
109
  == Changelog ==
110
 
111
+ = 3.0.12 (22nd September 2016) =
112
+ ** Requires PHP 5.4**
113
+ * Fixed close menu on link click bug with single header (Pro only)
114
+ * Fixed conflict bug with "close on link clicks" and "disable parent click" options
115
+ * Added header bar title link to WPML/Polylang
116
+ * Added alt tag option for every image
117
+ * Link target now taken into account with "Close Menu on Link Clicks"
118
+
119
  = 3.0.11 (29th August 2016) =
120
  ** Requires PHP 5.4**
121
  * Fixed export options bug (Pro only)
responsive-menu.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Responsive Menu
5
  Plugin URI: https://responsive.menu
6
  Description: Highly Customisable Responsive Menu Plugin for WordPress
7
- Version: 3.0.11
8
  Author: Responsive Menu
9
  Text Domain: responsive-menu
10
  Author URI: https://responsive.menu
4
  Plugin Name: Responsive Menu
5
  Plugin URI: https://responsive.menu
6
  Description: Highly Customisable Responsive Menu Plugin for WordPress
7
+ Version: 3.0.12
8
  Author: Responsive Menu
9
  Text Domain: responsive-menu
10
  Author URI: https://responsive.menu
src/app/Collections/OptionsCollection.php CHANGED
@@ -25,7 +25,7 @@ class OptionsCollection implements \ArrayAccess {
25
 
26
  public function getActiveArrow() {
27
  if($this->options['active_arrow_image'] && $this->options['active_arrow_image']->getValue())
28
- return '<img src="' . $this->options['active_arrow_image'] .'" />';
29
  else
30
  return $this->options['active_arrow_shape'];
31
 
@@ -33,7 +33,7 @@ class OptionsCollection implements \ArrayAccess {
33
 
34
  public function getInActiveArrow() {
35
  if($this->options['inactive_arrow_image'] && $this->options['inactive_arrow_image']->getValue())
36
- return '<img src="' . $this->options['inactive_arrow_image'] .'" />';
37
  else
38
  return $this->options['inactive_arrow_shape'];
39
 
@@ -41,7 +41,7 @@ class OptionsCollection implements \ArrayAccess {
41
 
42
  public function getTitleImage() {
43
  if($this->options['menu_title_image'] && $this->options['menu_title_image']->getValue())
44
- return '<img src="' . $this->options['menu_title_image'] .'" />';
45
  else
46
  return null;
47
 
@@ -49,14 +49,14 @@ class OptionsCollection implements \ArrayAccess {
49
 
50
  public function getButtonIcon() {
51
  if($this->options['button_image'] && $this->options['button_image']->getValue())
52
- return '<img src="' . $this->options['button_image'] .'" class="responsive-menu-button-icon responsive-menu-button-icon-active" />';
53
  else
54
  return '<span class="responsive-menu-inner"></span>';
55
  }
56
 
57
  public function getButtonIconActive() {
58
  if($this->options['button_image'] && $this->options['button_image']->getValue())
59
- return '<img src="' . $this->options['button_image_when_clicked'] .'" class="responsive-menu-button-icon responsive-menu-button-icon-inactive" />';
60
  }
61
 
62
  public function offsetExists($offset) {
25
 
26
  public function getActiveArrow() {
27
  if($this->options['active_arrow_image'] && $this->options['active_arrow_image']->getValue())
28
+ return '<img alt="' . $this->options['active_arrow_image_alt'] .'" src="' . $this->options['active_arrow_image'] .'" />';
29
  else
30
  return $this->options['active_arrow_shape'];
31
 
33
 
34
  public function getInActiveArrow() {
35
  if($this->options['inactive_arrow_image'] && $this->options['inactive_arrow_image']->getValue())
36
+ return '<img alt="' . $this->options['inactive_arrow_image_alt'] .'" src="' . $this->options['inactive_arrow_image'] .'" />';
37
  else
38
  return $this->options['inactive_arrow_shape'];
39
 
41
 
42
  public function getTitleImage() {
43
  if($this->options['menu_title_image'] && $this->options['menu_title_image']->getValue())
44
+ return '<img alt="' . $this->options['menu_title_image_alt'] .'" src="' . $this->options['menu_title_image'] .'" />';
45
  else
46
  return null;
47
 
49
 
50
  public function getButtonIcon() {
51
  if($this->options['button_image'] && $this->options['button_image']->getValue())
52
+ return '<img alt="' . $this->options['button_image_alt'] .'" src="' . $this->options['button_image'] .'" class="responsive-menu-button-icon responsive-menu-button-icon-active" />';
53
  else
54
  return '<span class="responsive-menu-inner"></span>';
55
  }
56
 
57
  public function getButtonIconActive() {
58
  if($this->options['button_image'] && $this->options['button_image']->getValue())
59
+ return '<img alt="' . $this->options['button_image_alt_when_clicked'] .'" src="' . $this->options['button_image_when_clicked'] .'" class="responsive-menu-button-icon responsive-menu-button-icon-inactive" />';
60
  }
61
 
62
  public function offsetExists($offset) {
src/app/Mappers/JsMapper.php CHANGED
@@ -145,14 +145,19 @@ class JsMapper {
145
  if(this.closeOnLinkClick == 'on') {
146
  $(this.linkElement).on('click', function(e) {
147
  e.preventDefault();
 
 
 
 
148
  old_href = $(this).attr('href');
 
149
  if(self.isOpen) {
150
  if($(e.target).closest('.responsive-menu-subarrow').length) {
151
  return;
152
  }
153
  self.closeMenu();
154
  setTimeout(function() {
155
- window.location = old_href;
156
  }, self.animationSpeed);
157
  }
158
  });
145
  if(this.closeOnLinkClick == 'on') {
146
  $(this.linkElement).on('click', function(e) {
147
  e.preventDefault();
148
+ /* Fix for when close menu on parent clicks is on */
149
+ if(self.itemTriggerSubMenu == 'on' && $(this).is('.responsive-menu-item-has-children > ' + self.linkElement)) {
150
+ return;
151
+ }
152
  old_href = $(this).attr('href');
153
+ old_target = typeof $(this).attr('target') == 'undefined' ? '_self' : $(this).attr('target');
154
  if(self.isOpen) {
155
  if($(e.target).closest('.responsive-menu-subarrow').length) {
156
  return;
157
  }
158
  self.closeMenu();
159
  setTimeout(function() {
160
+ window.open(old_href, old_target);
161
  }, self.animationSpeed);
162
  }
163
  });
src/app/Mappers/scss.inc.php CHANGED
@@ -3384,7 +3384,7 @@ class scss_parser_free {
3384
  if ($this->variable($out)) return true;
3385
  if ($this->color($out)) return true;
3386
  if ($this->unit($out)) return true;
3387
- if ($this->string($out)) return true;
3388
  if ($this->func($out)) return true;
3389
  if ($this->progid($out)) return true;
3390
 
@@ -3582,7 +3582,7 @@ class scss_parser_free {
3582
  return false;
3583
  }
3584
 
3585
- protected function string(&$out) {
3586
  $s = $this->seek();
3587
  if ($this->literal('"', false)) {
3588
  $delim = '"';
@@ -3695,7 +3695,7 @@ class scss_parser_free {
3695
  }
3696
  }
3697
 
3698
- if (($tok == "'" || $tok == '"') && $this->string($str)) {
3699
  $content[] = $str;
3700
  continue;
3701
  }
@@ -3939,7 +3939,7 @@ class scss_parser_free {
3939
  $attrParts[] = " ";
3940
  continue;
3941
  }
3942
- if ($this->string($str)) {
3943
  $attrParts[] = $str;
3944
  continue;
3945
  }
3384
  if ($this->variable($out)) return true;
3385
  if ($this->color($out)) return true;
3386
  if ($this->unit($out)) return true;
3387
+ if ($this->text($out)) return true;
3388
  if ($this->func($out)) return true;
3389
  if ($this->progid($out)) return true;
3390
 
3582
  return false;
3583
  }
3584
 
3585
+ protected function text(&$out) {
3586
  $s = $this->seek();
3587
  if ($this->literal('"', false)) {
3588
  $delim = '"';
3695
  }
3696
  }
3697
 
3698
+ if (($tok == "'" || $tok == '"') && $this->text($str)) {
3699
  $content[] = $str;
3700
  continue;
3701
  }
3939
  $attrParts[] = " ";
3940
  continue;
3941
  }
3942
+ if ($this->text($str)) {
3943
  $attrParts[] = $str;
3944
  continue;
3945
  }
src/app/Walkers/WpWalker.php CHANGED
@@ -29,6 +29,13 @@ class WpWalker extends \Walker_Nav_Menu {
29
  endswitch;
30
  endforeach;
31
 
 
 
 
 
 
 
 
32
  $class_names = join(' ', array_unique($responsive_menu_classes));
33
  $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
34
 
@@ -43,7 +50,6 @@ class WpWalker extends \Walker_Nav_Menu {
43
  $atts['href'] = ! empty( $item->url ) ? $item->url : '';
44
  $atts['class'] = 'responsive-menu-item-link';
45
 
46
-
47
  $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
48
 
49
  $attributes = '';
29
  endswitch;
30
  endforeach;
31
 
32
+ /* Clear child class if we are at the final depth level */
33
+ if(isset($responsive_menu_classes)):
34
+ if($depth + 1 == $this->options['menu_depth']->getValue() && ($key = array_search('responsive-menu-item-has-children', $responsive_menu_classes)) !== false) {
35
+ unset($responsive_menu_classes[$key]);
36
+ }
37
+ endif;
38
+
39
  $class_names = join(' ', array_unique($responsive_menu_classes));
40
  $class_names = $class_names ? ' class="' . esc_attr( $class_names ) . '"' : '';
41
 
50
  $atts['href'] = ! empty( $item->url ) ? $item->url : '';
51
  $atts['class'] = 'responsive-menu-item-link';
52
 
 
53
  $atts = apply_filters( 'nav_menu_link_attributes', $atts, $item, $args, $depth );
54
 
55
  $attributes = '';
src/config/admin_ordering.php CHANGED
@@ -139,6 +139,11 @@ $order_mapping = [
139
  'label' => __('', 'responsive-menu'),
140
  'type' => 'image'
141
  ],
 
 
 
 
 
142
  [
143
  'option' => 'menu_title_background_colour',
144
  'title' => __('Title Background Colour', 'responsive-menu'),
@@ -263,6 +268,13 @@ $order_mapping = [
263
  ],
264
  __('Background Colours', 'responsive-menu') =>
265
  [
 
 
 
 
 
 
 
266
  [
267
  'option' => 'menu_background_colour',
268
  'title' => __('Background Colour', 'responsive-menu'),
@@ -664,11 +676,21 @@ $order_mapping = [
664
  'label' => __('', 'responsive-menu'),
665
  'type' => 'image'
666
  ],
 
 
 
 
 
667
  [
668
  'option' => 'button_image_when_clicked',
669
  'title' => __('Image When Clicked', 'responsive-menu'),
670
  'label' => __('', 'responsive-menu'),
671
  'type' => 'image'
 
 
 
 
 
672
  ]
673
  ],
674
  __('Advanced', 'responsive-menu') =>
@@ -855,12 +877,22 @@ __('Sub-Menus', 'responsive-menu') => [
855
  'label' => __('', 'responsive-menu'),
856
  'type' => 'image'
857
  ],
 
 
 
 
 
858
  [
859
  'option' => 'inactive_arrow_image',
860
  'title' => __('Image Inactive', 'responsive-menu'),
861
  'label' => __('', 'responsive-menu'),
862
  'type' => 'image'
863
  ],
 
 
 
 
 
864
  [
865
  'option' => 'arrow_position',
866
  'title' => __('Icon Position', 'responsive-menu'),
@@ -1004,6 +1036,12 @@ __('Sub-Menus', 'responsive-menu') => [
1004
  'type' => 'image',
1005
  'pro' => true
1006
  ],
 
 
 
 
 
 
1007
  [
1008
  'option' => 'header_bar_logo_link',
1009
  'title' => __('Link', 'responsive-menu'),
139
  'label' => __('', 'responsive-menu'),
140
  'type' => 'image'
141
  ],
142
+ [
143
+ 'option' => 'menu_title_image_alt',
144
+ 'title' => __('Alt Text', 'responsive-menu'),
145
+ 'label' => __('', 'responsive-menu'),
146
+ ],
147
  [
148
  'option' => 'menu_title_background_colour',
149
  'title' => __('Title Background Colour', 'responsive-menu'),
268
  ],
269
  __('Background Colours', 'responsive-menu') =>
270
  [
271
+ [
272
+ 'option' => 'menu_background_image',
273
+ 'title' => __('Background Image', 'responsive-menu'),
274
+ 'label' => __('', 'responsive-menu'),
275
+ 'type' => 'image',
276
+ 'pro' => true
277
+ ],
278
  [
279
  'option' => 'menu_background_colour',
280
  'title' => __('Background Colour', 'responsive-menu'),
676
  'label' => __('', 'responsive-menu'),
677
  'type' => 'image'
678
  ],
679
+ [
680
+ 'option' => 'button_image_alt',
681
+ 'title' => __('Alt Text', 'responsive-menu'),
682
+ 'label' => __('', 'responsive-menu')
683
+ ],
684
  [
685
  'option' => 'button_image_when_clicked',
686
  'title' => __('Image When Clicked', 'responsive-menu'),
687
  'label' => __('', 'responsive-menu'),
688
  'type' => 'image'
689
+ ],
690
+ [
691
+ 'option' => 'button_image_alt_when_clicked',
692
+ 'title' => __('Alt Text', 'responsive-menu'),
693
+ 'label' => __('', 'responsive-menu')
694
  ]
695
  ],
696
  __('Advanced', 'responsive-menu') =>
877
  'label' => __('', 'responsive-menu'),
878
  'type' => 'image'
879
  ],
880
+ [
881
+ 'option' => 'active_arrow_image_alt',
882
+ 'title' => __('Alt Text', 'responsive-menu'),
883
+ 'label' => __('', 'responsive-menu')
884
+ ],
885
  [
886
  'option' => 'inactive_arrow_image',
887
  'title' => __('Image Inactive', 'responsive-menu'),
888
  'label' => __('', 'responsive-menu'),
889
  'type' => 'image'
890
  ],
891
+ [
892
+ 'option' => 'inactive_arrow_image_alt',
893
+ 'title' => __('Alt Text', 'responsive-menu'),
894
+ 'label' => __('', 'responsive-menu')
895
+ ],
896
  [
897
  'option' => 'arrow_position',
898
  'title' => __('Icon Position', 'responsive-menu'),
1036
  'type' => 'image',
1037
  'pro' => true
1038
  ],
1039
+ [
1040
+ 'option' => 'header_bar_logo_alt',
1041
+ 'title' => __('Alt Text', 'responsive-menu'),
1042
+ 'label' => __('', 'responsive-menu'),
1043
+ 'pro' => true
1044
+ ],
1045
  [
1046
  'option' => 'header_bar_logo_link',
1047
  'title' => __('Link', 'responsive-menu'),
src/config/default_options.php CHANGED
@@ -11,7 +11,9 @@ $default_options = [
11
  // Button Settings
12
  'button_title' => null,
13
  'button_image' => null,
 
14
  'button_image_when_clicked' => null,
 
15
  'button_font' => null,
16
  'button_font_icon' => null,
17
  'button_font_icon_when_clicked' => null,
@@ -46,7 +48,9 @@ $default_options = [
46
  'active_arrow_shape' => '▲',
47
  'inactive_arrow_shape' => '▼',
48
  'active_arrow_image' => '',
 
49
  'inactive_arrow_image' => '',
 
50
  'active_arrow_font_icon' => '',
51
  'inactive_arrow_font_icon' => '',
52
  'arrow_position' => 'right',
@@ -57,6 +61,7 @@ $default_options = [
57
  'auto_expand_current_submenus' => 'off',
58
 
59
  'menu_background_colour' => '#212121',
 
60
  'menu_item_background_colour' => '#212121',
61
  'menu_item_background_hover_colour' => '#3f3f3f',
62
  'menu_item_border_colour' => '#212121',
@@ -97,6 +102,7 @@ $default_options = [
97
  'menu_additional_content_colour' => '#fff',
98
  'menu_title' => null,
99
  'menu_title_image' => null,
 
100
  'menu_title_font_icon' => null,
101
  'menu_appear_from' => 'left',
102
  'menu_title_link' => null,
@@ -148,6 +154,7 @@ $default_options = [
148
  'use_header_bar' => 'off',
149
  'header_bar_breakpoint' => '800',
150
  'header_bar_logo' => null,
 
151
  'header_bar_logo_link' => null,
152
  'header_bar_title' => null,
153
  'header_bar_html_content' => null,
@@ -158,7 +165,7 @@ $default_options = [
158
  'header_bar_text_color' => '#ffffff',
159
  'header_bar_position_type' => 'fixed',
160
 
161
- 'items_order' => '{"title": "on","menu":"on","search":"on","additional content":"on"}',
162
- 'header_bar_items_order' => '{"logo": "on","title":"on","search":"on","html content":"on","button":"on"}',
163
 
164
  ];
11
  // Button Settings
12
  'button_title' => null,
13
  'button_image' => null,
14
+ 'button_image_alt' => null,
15
  'button_image_when_clicked' => null,
16
+ 'button_image_alt_when_clicked' => null,
17
  'button_font' => null,
18
  'button_font_icon' => null,
19
  'button_font_icon_when_clicked' => null,
48
  'active_arrow_shape' => '▲',
49
  'inactive_arrow_shape' => '▼',
50
  'active_arrow_image' => '',
51
+ 'active_arrow_image_alt' => '',
52
  'inactive_arrow_image' => '',
53
+ 'inactive_arrow_image_alt' => '',
54
  'active_arrow_font_icon' => '',
55
  'inactive_arrow_font_icon' => '',
56
  'arrow_position' => 'right',
61
  'auto_expand_current_submenus' => 'off',
62
 
63
  'menu_background_colour' => '#212121',
64
+ 'menu_background_image' => '',
65
  'menu_item_background_colour' => '#212121',
66
  'menu_item_background_hover_colour' => '#3f3f3f',
67
  'menu_item_border_colour' => '#212121',
102
  'menu_additional_content_colour' => '#fff',
103
  'menu_title' => null,
104
  'menu_title_image' => null,
105
+ 'menu_title_image_alt' => null,
106
  'menu_title_font_icon' => null,
107
  'menu_appear_from' => 'left',
108
  'menu_title_link' => null,
154
  'use_header_bar' => 'off',
155
  'header_bar_breakpoint' => '800',
156
  'header_bar_logo' => null,
157
+ 'header_bar_logo_alt' => '',
158
  'header_bar_logo_link' => null,
159
  'header_bar_title' => null,
160
  'header_bar_html_content' => null,
165
  'header_bar_text_color' => '#ffffff',
166
  'header_bar_position_type' => 'fixed',
167
 
168
+ 'items_order' => '{"title":"on","menu":"on","search":"on","additional content":"on"}',
169
+ 'header_bar_items_order' => '{"logo":"on","title":"on","search":"on","html content":"on","button":"on"}',
170
 
171
  ];
src/config/option_helpers.php CHANGED
@@ -4,6 +4,9 @@ $option_helpers = [
4
  'menu_font_icons' => [
5
  'filter' => 'ResponsiveMenu\Filters\JsonFilter'
6
  ],
 
 
 
7
  'menu_additional_content' => [
8
  'filter' => 'ResponsiveMenu\Filters\HtmlFilter'
9
  ],
4
  'menu_font_icons' => [
5
  'filter' => 'ResponsiveMenu\Filters\JsonFilter'
6
  ],
7
+ 'menu_title' => [
8
+ 'filter' => 'ResponsiveMenu\Filters\HtmlFilter'
9
+ ],
10
  'menu_additional_content' => [
11
  'filter' => 'ResponsiveMenu\Filters\HtmlFilter'
12
  ],
src/config/services.php CHANGED
@@ -3,7 +3,7 @@
3
  $container = new ResponsiveMenu\Routing\Container();
4
 
5
  $container['current_version'] = function($c) {
6
- return '3.0.11';
7
  };
8
 
9
  $container['option_helpers'] = function($c) {
3
  $container = new ResponsiveMenu\Routing\Container();
4
 
5
  $container['current_version'] = function($c) {
6
+ return '3.0.12';
7
  };
8
 
9
  $container['option_helpers'] = function($c) {
tests/app/Collections/OptionsCollectionTest.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class OptionsCollectionTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->collection = new ResponsiveMenu\Collections\OptionsCollection;
9
+ }
10
+
11
+ public function testAddingOptionReturnTypes() {
12
+ $this->collection->add(new ResponsiveMenu\Models\Option('a', 'a'));
13
+ $all_options = $this->collection->all();
14
+ $this->assertInternalType('array', $all_options);
15
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $all_options['a']);
16
+ }
17
+
18
+ public function testAddingMultipleOptionReturnTypes() {
19
+ $this->collection->add(new ResponsiveMenu\Models\Option('a', 'a'));
20
+ $this->collection->add(new ResponsiveMenu\Models\Option('b', 'b'));
21
+ $all_options = $this->collection->all();
22
+ $this->assertInternalType('array', $all_options);
23
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $all_options['a']);
24
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $all_options['b']);
25
+ }
26
+
27
+ public function testAddingOptionGetOptionReturnTypes() {
28
+ $this->collection->add(new ResponsiveMenu\Models\Option('a', 'a'));
29
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $this->collection->get('a'));
30
+ }
31
+
32
+ public function testAddingMultipleOptionGetOptionReturnTypes() {
33
+ $this->collection->add(new ResponsiveMenu\Models\Option('a', 'a'));
34
+ $this->collection->add(new ResponsiveMenu\Models\Option('b', 'b'));
35
+
36
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $this->collection->get('a'));
37
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $this->collection->get('b'));
38
+ }
39
+
40
+ public function testUsesFontAwesomeIcons() {
41
+ $this->assertFalse($this->collection->usesFontIcons());
42
+ }
43
+
44
+ public function testGetActiveArrow() {
45
+ $this->collection->add(new ResponsiveMenu\Models\Option('active_arrow_image', 'test.jpg'));
46
+ $this->collection->add(new ResponsiveMenu\Models\Option('active_arrow_image_alt', 'test-alt'));
47
+ $this->assertEquals('<img alt="test-alt" src="test.jpg" />', $this->collection->getActiveArrow());
48
+ }
49
+
50
+ public function testGetActiveArrowDoesntExist() {
51
+ $this->collection->add(new ResponsiveMenu\Models\Option('active_arrow_image', ''));
52
+ $this->collection->add(new ResponsiveMenu\Models\Option('active_arrow_shape', 'arrow'));
53
+ $this->assertEquals('arrow', $this->collection->getActiveArrow());
54
+ }
55
+
56
+ public function testGetInactiveArrow() {
57
+ $this->collection->add(new ResponsiveMenu\Models\Option('inactive_arrow_image', 'test.jpg'));
58
+ $this->collection->add(new ResponsiveMenu\Models\Option('inactive_arrow_image_alt', 'test-alt'));
59
+ $this->assertEquals('<img alt="test-alt" src="test.jpg" />', $this->collection->getInActiveArrow());
60
+ }
61
+
62
+ public function testGetInactiveArrowDoesntExist() {
63
+ $this->collection->add(new ResponsiveMenu\Models\Option('inactive_arrow_image', ''));
64
+ $this->collection->add(new ResponsiveMenu\Models\Option('inactive_arrow_shape', 'arrow'));
65
+ $this->assertEquals('arrow', $this->collection->getInActiveArrow());
66
+ }
67
+
68
+ public function testGetInactiveTitleImage() {
69
+ $this->collection->add(new ResponsiveMenu\Models\Option('menu_title_image', 'test.jpg'));
70
+ $this->collection->add(new ResponsiveMenu\Models\Option('menu_title_image_alt', 'test-alt'));
71
+ $this->assertEquals('<img alt="test-alt" src="test.jpg" />', $this->collection->getTitleImage());
72
+ }
73
+
74
+ public function testGetInactiveTitleImageDoesntExist() {
75
+ $this->collection->add(new ResponsiveMenu\Models\Option('menu_title_image', ''));
76
+ $this->collection->add(new ResponsiveMenu\Models\Option('menu_title_image_alt', ''));
77
+ $this->assertEquals(null, $this->collection->getTitleImage());
78
+ }
79
+
80
+ public function testGetButtonIcon() {
81
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image', 'test.jpg'));
82
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image_alt', 'test-alt'));
83
+ $this->assertEquals('<img alt="test-alt" src="test.jpg" class="responsive-menu-button-icon responsive-menu-button-icon-active" />', $this->collection->getButtonIcon());
84
+ }
85
+
86
+ public function testGetButtonIconDoesntExist() {
87
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image', ''));
88
+ $this->assertEquals('<span class="responsive-menu-inner"></span>', $this->collection->getButtonIcon());
89
+ }
90
+
91
+ public function testGetButtonIconActive() {
92
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image', 'test2.jpg'));
93
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image_alt', 'alt-a'));
94
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image_when_clicked', 'test.jpg'));
95
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image_alt_when_clicked', 'alt-b'));
96
+ $this->assertEquals('<img alt="alt-b" src="test.jpg" class="responsive-menu-button-icon responsive-menu-button-icon-inactive" />', $this->collection->getButtonIconActive());
97
+ }
98
+
99
+ public function testGetButtonIconActiveDoesntExist() {
100
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image', ''));
101
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image_alt', ''));
102
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image_when_clicked', 'test.jpg'));
103
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image_alt_when_clicked', 'test.jpg'));
104
+ $this->assertEquals(null, $this->collection->getButtonIconActive());
105
+ }
106
+
107
+ public function testIsCollectionEmpty() {
108
+ $this->assertTrue($this->collection->isEmpty());
109
+ }
110
+
111
+ public function testIsCollectionEmptyNotEmpty() {
112
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image', 'test.jpg'));
113
+ $this->collection->add(new ResponsiveMenu\Models\Option('button_image_alt', 'test.jpg'));
114
+ $this->assertFalse($this->collection->isEmpty());
115
+ }
116
+
117
+ public function testArrayAccessGetFunctions() {
118
+ $this->collection->add(new ResponsiveMenu\Models\Option('a', 'a'));
119
+ $this->collection->add(new ResponsiveMenu\Models\Option('b', 'b'));
120
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $this->collection['a']);
121
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $this->collection['b']);
122
+ }
123
+
124
+ public function testArrayAccessSetFunctions() {
125
+ $this->collection['a'] = new ResponsiveMenu\Models\Option('a', 'a');
126
+ $this->collection['b'] = new ResponsiveMenu\Models\Option('b', 'b');
127
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $this->collection->get('a'));
128
+ $this->assertInstanceOf('ResponsiveMenu\Models\Option', $this->collection->get('b'));
129
+ }
130
+
131
+ public function testArrayAccessUnSetFunctions() {
132
+ $this->collection['a'] = new ResponsiveMenu\Models\Option('a', 'a');
133
+ $this->collection['b'] = new ResponsiveMenu\Models\Option('b', 'b');
134
+ unset($this->collection['b']);
135
+ $this->assertArrayNotHasKey('b', $this->collection);
136
+ }
137
+
138
+ }
tests/app/Controllers/AdminTest.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+ use ResponsiveMenu\Collections\OptionsCollection;
5
+ use ResponsiveMenu\Models\Option;
6
+
7
+ class AdminTest extends TestCase {
8
+
9
+ static public function setUpBeforeClass() {
10
+ function __($a, $b) {
11
+ return $a;
12
+ }
13
+ }
14
+ public function setUp() {
15
+ $this->view = $this->createMock('ResponsiveMenu\View\AdminView');
16
+ $this->service = $this->createMock('ResponsiveMenu\Services\OptionService');
17
+ $this->view->method('render')->willReturn(true);
18
+ $this->view->method('display')->will($this->returnArgument(0));
19
+ $this->service->method('combineOptions')->willReturn([]);
20
+ $collection = new OptionsCollection;
21
+ $collection->add(new Option('a', 1));
22
+ $this->service->method('all')->willReturn($collection);
23
+ $this->controller = new ResponsiveMenu\Controllers\Admin($this->service, $this->view);
24
+
25
+ }
26
+
27
+ public function testUpdate() {
28
+ $this->assertTrue($this->controller->update([],[]));
29
+ }
30
+
31
+ public function testReset() {
32
+ $this->assertTrue($this->controller->reset([]));
33
+ }
34
+
35
+ public function testIndex() {
36
+ $this->assertTrue($this->controller->index([]));
37
+ }
38
+
39
+ public function testExport() {
40
+ $this->assertNull($this->controller->export());
41
+ }
42
+
43
+ public function testImportNoFile() {
44
+ $this->assertTrue($this->controller->import(['a' => 1], null));
45
+ }
46
+
47
+ public function testImport() {
48
+ $this->assertTrue($this->controller->import(['a' => 1], ['b' => 2]));
49
+ }
50
+
51
+ }
tests/app/Controllers/FrontTest.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+ use ResponsiveMenu\Collections\OptionsCollection;
5
+ use ResponsiveMenu\Models\Option;
6
+
7
+ class FrontTest extends TestCase {
8
+
9
+ public function setUp() {
10
+ $this->view = $this->createMock('ResponsiveMenu\View\FrontView');
11
+ $this->service = $this->createMock('ResponsiveMenu\Services\OptionService');
12
+ $this->menu = $this->createMock('ResponsiveMenu\ViewModels\Menu');
13
+ $this->button = $this->createMock('ResponsiveMenu\ViewModels\Button');
14
+ $this->collection = new OptionsCollection;
15
+
16
+ $this->view->method('render')->willReturn('rendered');
17
+ $this->controller = new ResponsiveMenu\Controllers\Front($this->service, $this->view, $this->menu, $this->button);
18
+
19
+ }
20
+
21
+ public function testPreview() {
22
+ $this->assertEquals('rendered', $this->controller->preview());
23
+ }
24
+
25
+ public function testIndexShortcodeIsNotCalled() {
26
+ $this->collection->add(new Option('shortcode', 'off'));
27
+ $this->service->method('all')->willReturn($this->collection);
28
+ $this->assertEquals('rendered', $this->controller->index());
29
+ }
30
+
31
+ public function testIndexShortcodeIsCalled() {
32
+ $this->service->method('all')->willReturn($this->collection);
33
+ $this->view->method('addShortcode')->willReturn('shortcode added');
34
+ $this->assertEquals('shortcode added', $this->controller->index());
35
+ }
36
+
37
+ }
tests/app/Database/MigrationTest.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+ use ResponsiveMenu\Collections\OptionsCollection;
5
+ use ResponsiveMenu\Database\Migration;
6
+ use ResponsiveMenu\Models\Option;
7
+
8
+ class MigrationTest extends TestCase {
9
+
10
+ public function setUp() {
11
+ $this->database = $this->createMock('ResponsiveMenu\Database\WpDatabase');
12
+ $this->service = $this->createMock('ResponsiveMenu\Services\OptionService');
13
+ $this->defaults = ['default_one' => 1, 'default_two' => 'string', 'default_three' => 4.5, 'default_four' => 'new'];
14
+ $this->current_version = '3.0.8';
15
+ $this->old_version = '3.0.7';
16
+ $this->old_options = ['default_one' => 4, 'default_two' => 'old string', 'default_three' => 4.5, 'RM' => 'old RM value', 'RMDepth' => 'old RMDepth value'];
17
+
18
+ $this->base_migration = new Migration($this->database, $this->service, $this->defaults, $this->current_version, $this->old_version, $this->old_options);
19
+
20
+ $this->options_collection = new OptionsCollection;
21
+ $this->options_collection->add(new Option('default_one', 5));
22
+ $this->options_collection->add(new Option('default_two', 'string'));
23
+ $this->options_collection->add(new Option('default_three', 7.5));
24
+
25
+ /*
26
+ * Mock the repository all() function to return controlled options collection
27
+ */
28
+ $service_options = new OptionsCollection;
29
+ $service_options->add(new Option('default_one', 5));
30
+ $service_options->add(new Option('default_two', 'new option'));
31
+ $service_options->add(new Option('to_delete', 'delete me!'));
32
+ $service_options->add(new Option('to_delete_also', 'delete me too!'));
33
+ $this->service->method('all')->willReturn($service_options);
34
+
35
+ }
36
+
37
+ public function testVersionCompareNeedsUpdate() {
38
+ $this->assertTrue($this->base_migration->needsUpdate());
39
+ }
40
+
41
+ public function testVersionCompareDoesntNeedUpdate() {
42
+ $migration = new Migration($this->database, $this->service, $this->defaults, $this->current_version, '3.0.9', $this->old_options);
43
+ $this->assertFalse($migration->needsUpdate());
44
+ }
45
+
46
+ public function testVersionCompareNeedUpdateWithDoubleEndPoint() {
47
+ $migration = new Migration($this->database, $this->service, $this->defaults, '3.0.10', $this->old_version, $this->old_options);
48
+ $this->assertTrue($migration->needsUpdate());
49
+ }
50
+
51
+ public function testVersionCompareDoesntNeedUpdateWithDoubleEndPoint() {
52
+ $migration = new Migration($this->database, $this->service, $this->defaults, '3.0.10', '3.1.0', $this->old_options);
53
+ $this->assertFalse($migration->needsUpdate());
54
+ }
55
+
56
+ public function testVersionCompareDoesNeedUpdateWithTenComparedToOne() {
57
+ $migration = new Migration($this->database, $this->service, $this->defaults, '3.0.10', '3.0.1', $this->old_options);
58
+ $this->assertTrue($migration->needsUpdate());
59
+ }
60
+
61
+ public function testVersionCompareDoesntNeedUpdateWithOneComparedToTen() {
62
+ $migration = new Migration($this->database, $this->service, $this->defaults, '3.0.1', '3.0.10', $this->old_options);
63
+ $this->assertFalse($migration->needsUpdate());
64
+ }
65
+
66
+ public function testVersionCompareDoesntNeedUpdateWithDoubleEndPointWithVersionHigher() {
67
+ $migration = new Migration($this->database, $this->service, $this->defaults, '3.0.10', '3.2.0', $this->old_options);
68
+ $this->assertFalse($migration->needsUpdate());
69
+ }
70
+
71
+ public function testVersionCompareDoesNeedUpdateWithDoubleEndPointWithVersionHigher() {
72
+ $migration = new Migration($this->database, $this->service, $this->defaults, '3.2.0', '3.0.10', $this->old_options);
73
+ $this->assertTrue($migration->needsUpdate());
74
+ }
75
+
76
+ public function testNewOptionsReturnedAreCorrect() {
77
+ $this->assertSame(['default_four' => 'new'], $this->base_migration->getNewOptions($this->options_collection));
78
+ }
79
+
80
+ public function testIsVersion3CheckReturnsFalse() {
81
+ $migration = new Migration($this->database, $this->service, $this->defaults, $this->current_version, '2.8.0', $this->old_options);
82
+ $this->assertFalse($migration->isVersion3());
83
+ }
84
+
85
+ public function testIsVersion3CheckReturnsTrue() {
86
+ $this->assertTrue($this->base_migration->isVersion3());
87
+ }
88
+
89
+ public function testDeletableOptions() {
90
+ $this->assertSame(['to_delete' => 'to_delete', 'to_delete_also' => 'to_delete_also'], $this->base_migration->getOptionsToDelete());
91
+ }
92
+
93
+ public function testOptionsToMigrate() {
94
+ $this->assertSame(['menu_to_use' => 'old RM value', 'menu_depth' => 'old RMDepth value'], $this->base_migration->getMigratedOptions());
95
+ }
96
+
97
+ public function testSetup() {
98
+ $this->database->method('createTable')->willReturn(true);
99
+ $migration = new Migration($this->database, $this->service, $this->defaults, '3.0.10', '2.8.9', $this->old_options);
100
+ $this->assertEquals(null, $migration->setUp());
101
+ }
102
+
103
+ public function testSynchronise() {
104
+ $this->assertEquals(null, $this->base_migration->synchronise());
105
+ }
106
+
107
+ public function testAddNewOptionsEmpty() {
108
+ $service = $this->createMock('ResponsiveMenu\Services\OptionService');
109
+ $service->method('all')->willReturn(new ResponsiveMenu\Collections\OptionsCollection);
110
+ $migration = new Migration($this->database, $service, $this->defaults, $this->current_version, $this->old_version, $this->old_options);
111
+ $this->assertEquals(null, $migration->addNewOptions());
112
+ }
113
+
114
+ }
tests/app/Database/WpDatabaseTest.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+ use ResponsiveMenu\Database\WpDatabase;
5
+
6
+ class WpDatabaseTest extends TestCase {
7
+
8
+ public function setUp() {
9
+ $this->wpdb = $this->getMockBuilder('wpdb')
10
+ ->setMethods(['update', 'delete', 'get_results', 'insert', 'select'])
11
+ ->getMock();
12
+ $this->wpdb->prefix = 'prefix';
13
+ $this->db = new WpDatabase($this->wpdb);
14
+
15
+ if(!function_exists('current_time')):
16
+ function current_time($type) {
17
+ return '0000';
18
+ }
19
+ endif;
20
+
21
+ if(!function_exists('update_option')):
22
+ function update_option($a, $b) {
23
+ return $a . ' ' . $b;
24
+ }
25
+ endif;
26
+ }
27
+
28
+ public function testUpdate() {
29
+ $this->wpdb->method('update')->will($this->returnArgument(0));
30
+ $this->assertEquals('prefixupdate_arg', $this->db->update('update_arg', [], []));
31
+ }
32
+
33
+ public function testDelete() {
34
+ $this->wpdb->method('delete')->will($this->returnArgument(0));
35
+ $this->assertEquals('prefixdelete_arg', $this->db->delete('delete_arg', 'b'));
36
+ }
37
+
38
+ public function testGetResults() {
39
+ $this->wpdb->method('get_results')->will($this->returnArgument(0));
40
+ $this->assertEquals('SELECT * FROM prefixget_results_arg', $this->db->all('get_results_arg'));
41
+ }
42
+
43
+ public function testInsertResults() {
44
+ $this->wpdb->method('insert')->will($this->returnArgument(0));
45
+ $this->assertEquals('prefixinsert_arg', $this->db->insert('insert_arg', []));
46
+ }
47
+
48
+ public function testSelectResults() {
49
+ $this->wpdb->method('get_results')->will($this->returnArgument(0));
50
+ $this->assertEquals('SELECT * FROM prefixselect_arg WHERE a = \'b\';', $this->db->select('select_arg', 'a', 'b'));
51
+ }
52
+
53
+ public function testMySqlTime() {
54
+ $this->assertEquals('0000', $this->db->mySqlTime());
55
+ }
56
+
57
+ public function testUpdateOption() {
58
+ $this->assertEquals('a b', $this->db->updateOption('a', 'b'));
59
+ }
60
+
61
+ }
tests/app/Factories/CssFactoryTest.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+ use ResponsiveMenu\Factories\CssFactory;
5
+ use ResponsiveMenu\Collections\OptionsCollection;
6
+ use ResponsiveMenu\Models\Option;
7
+
8
+ class CssFactoryTest extends TestCase {
9
+
10
+ public function setUp() {
11
+ $this->base_mapper = $this->createMock('ResponsiveMenu\Mappers\ScssBaseMapper');
12
+ $this->button_mapper = $this->createMock('ResponsiveMenu\Mappers\ScssButtonMapper');
13
+ $this->menu_mapper = $this->createMock('ResponsiveMenu\Mappers\ScssMenuMapper');
14
+ $this->minifier = $this->createMock('ResponsiveMenu\Formatters\Minify');
15
+
16
+ $this->base_mapper->method('map')->willReturn('a');
17
+ $this->button_mapper->method('map')->willReturn('b');
18
+ $this->menu_mapper->method('map')->willReturn('c');
19
+ $this->minifier->method('minify')->willReturn('d');
20
+ $this->factory = new CssFactory($this->minifier, $this->base_mapper, $this->button_mapper, $this->menu_mapper);
21
+ }
22
+
23
+ public function testMinified() {
24
+ $collection = new OptionsCollection;
25
+ $collection->add(new Option('minify_scripts', 'on'));
26
+ $this->assertequals('d', $this->factory->build($collection));
27
+ }
28
+
29
+ public function testNotMinified() {
30
+ $collection = new OptionsCollection;
31
+ $collection->add(new Option('minify_scripts', 'off'));
32
+ $this->assertequals('abc', $this->factory->build($collection));
33
+ }
34
+
35
+ }
tests/app/Factories/JsFactoryTest.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+ use ResponsiveMenu\Factories\JsFactory;
5
+ use ResponsiveMenu\Collections\OptionsCollection;
6
+ use ResponsiveMenu\Models\Option;
7
+
8
+ class JsFactoryTest extends TestCase {
9
+
10
+ public function setUp() {
11
+ $this->mapper = $this->createMock('ResponsiveMenu\Mappers\JsMapper');
12
+ $this->minifier = $this->createMock('ResponsiveMenu\Formatters\Minify');
13
+ $this->mapper->method('map')->willReturn('a');
14
+ $this->minifier->method('minify')->willReturn('b');
15
+ $this->factory = new JsFactory($this->mapper, $this->minifier);
16
+ }
17
+
18
+ public function testMinified() {
19
+ $collection = new OptionsCollection;
20
+ $collection->add(new Option('minify_scripts', 'on'));
21
+ $this->assertequals('b', $this->factory->build($collection));
22
+ }
23
+
24
+ public function testNotMinified() {
25
+ $collection = new OptionsCollection;
26
+ $collection->add(new Option('minify_scripts', 'off'));
27
+ $this->assertequals('a', $this->factory->build($collection));
28
+ }
29
+
30
+ }
tests/app/Factories/OptionFactoryTest.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
tests/app/Filesystem/FileCreatorTest.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class FileCreatorTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->creator = new ResponsiveMenu\Filesystem\FileCreator;
9
+ }
10
+
11
+ public function testCreate() {
12
+ $this->assertTrue($this->creator->create(dirname(__FILE__), 'test.txt','a'));
13
+ $this->assertEquals('a', file_get_contents(dirname(__FILE__) . '/test.txt'));
14
+ }
15
+
16
+ public function testFailToCreate() {
17
+ $this->assertFalse($this->creator->create('', 'test.txt','a'));
18
+ }
19
+
20
+ public function tearDown() {
21
+ if(file_exists(dirname(__FILE__). '/test.txt'))
22
+ unlink(dirname(__FILE__). '/test.txt');
23
+ }
24
+
25
+ }
tests/app/Filesystem/FolderCreatorTest.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class FolderCreatorTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->creator = new ResponsiveMenu\Filesystem\FolderCreator;
9
+ $this->dir = dirname(__FILE__) . '/tmp';
10
+ }
11
+
12
+ public function testCreate() {
13
+ $this->creator->create($this->dir);
14
+ $this->assertTrue($this->creator->exists($this->dir));
15
+ }
16
+
17
+ public function tearDown() {
18
+ rmdir($this->dir);
19
+ }
20
+
21
+ }
tests/app/Filesystem/ScriptsBuilderTest.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class ScriptsBuilderTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->files = $this->createMock('ResponsiveMenu\Filesystem\FileCreator');
9
+ $this->folders = $this->createMock('ResponsiveMenu\Filesystem\FolderCreator');
10
+ $this->css = $this->createMock('ResponsiveMenu\Factories\CssFactory');
11
+ $this->js = $this->createMock('ResponsiveMenu\Factories\JsFactory');
12
+ $this->collection = $this->createMock('ResponsiveMenu\Collections\OptionsCollection');
13
+ $this->id = 2;
14
+
15
+ $this->builder = new ResponsiveMenu\Filesystem\ScriptsBuilder($this->css, $this->js, $this->files, $this->folders, $this->id);
16
+
17
+ }
18
+
19
+ public function testBuild() {
20
+ $this->assertEquals(null, $this->builder->build($this->collection));
21
+ }
22
+
23
+ }
tests/app/Filters/HtmlFilterTest.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class HtmlFilterTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->filter = new ResponsiveMenu\Filters\HtmlFilter;
9
+ }
10
+
11
+ public function testFiltered() {
12
+ $this->assertEquals('a', $this->filter->filter('a'));
13
+ }
14
+
15
+ }
tests/app/Filters/JsonFilterTest.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class JsonFilterTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->filter = new ResponsiveMenu\Filters\JsonFilter;
9
+ }
10
+
11
+ public function testFilteredWithString() {
12
+ $this->assertEquals('{"a":1,"b":2}', $this->filter->filter('{"a":1,"b":2}'));
13
+ }
14
+
15
+ public function testFilteredWithArray() {
16
+ $this->assertEquals('{"a":1,"b":2}', $this->filter->filter(['a' => 1, 'b' => 2]));
17
+ }
18
+
19
+ }
tests/app/Filters/TextFilterTest.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class TextFilterTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->filter = new ResponsiveMenu\Filters\TextFilter;
9
+ }
10
+
11
+ public function testFilteredWithString() {
12
+ $this->assertEquals('a', $this->filter->filter('a'));
13
+ }
14
+
15
+ public function testFilteredWithHtml() {
16
+ $this->assertEquals('a', $this->filter->filter('<span class="test">a</span>'));
17
+ }
18
+
19
+ }
tests/app/Form/CheckboxTest.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class CheckboxTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->form_component = new ResponsiveMenu\Form\Checkbox;
9
+ }
10
+
11
+ public function testRendering() {
12
+ $output = $this->form_component->render(new ResponsiveMenu\Models\Option('a', 1));
13
+ $this->assertEquals("<div class='onoffswitch'>
14
+ <input type='checkbox' class='checkbox onoffswitch-checkbox' id='a' name='menu[a]' value='on' />
15
+ <label class='onoffswitch-label' for='a'>
16
+ <span class='onoffswitch-inner'></span>
17
+ <span class='onoffswitch-switch'></span>
18
+ </label>
19
+ </div>", $output);
20
+ }
21
+
22
+ public function testRenderingTurnedOn() {
23
+ $output = $this->form_component->render(new ResponsiveMenu\Models\Option('a', 'on'));
24
+ $this->assertEquals("<div class='onoffswitch'>
25
+ <input type='checkbox' class='checkbox onoffswitch-checkbox' id='a' checked='checked' name='menu[a]' value='on' />
26
+ <label class='onoffswitch-label' for='a'>
27
+ <span class='onoffswitch-inner'></span>
28
+ <span class='onoffswitch-switch'></span>
29
+ </label>
30
+ </div>", $output);
31
+ }
32
+
33
+ }
tests/app/Form/ColourTest.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class ColourTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->form_component = new ResponsiveMenu\Form\Colour;
9
+ }
10
+
11
+ public function testRendering() {
12
+ $output = $this->form_component->render(new ResponsiveMenu\Models\Option('a', 1));
13
+ $this->assertEquals("<input type='text' class='colour wp-color-picker' id='a' name='menu[a]' value='1' />", $output);
14
+ }
15
+
16
+ }
tests/app/Form/ExportTest.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class ExportTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->form_component = new ResponsiveMenu\Form\Export;
9
+ }
10
+
11
+ public function testRendering() {
12
+ $output = $this->form_component->render();
13
+ $this->assertEquals('<input type="submit" class="button submit" name="responsive_menu_export" value="Export Options" />', $output);
14
+ }
15
+
16
+ }
tests/app/Form/FontIconPageListTest.php ADDED
File without changes
tests/app/Form/FontIconTest.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class FontIconPageListTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->form_component = new ResponsiveMenu\Form\FontIconPageList;
9
+ }
10
+
11
+ public function testRendering() {
12
+ $output = $this->form_component->render(new ResponsiveMenu\Models\Option('a', '{"id":["1", "2"],"icon":["a", "b"]}'));
13
+ $this->assertContains("class='a_icon'", $output);
14
+ $this->assertContains("value='2'", $output);
15
+ $this->assertContains("value='b'", $output);
16
+ }
17
+
18
+ public function testRenderingWhenEmpty() {
19
+ $output = $this->form_component->render(new ResponsiveMenu\Models\Option('a', 'b'));
20
+ $this->assertContains("class='a_icon'", $output);
21
+ }
22
+
23
+ }
tests/app/Form/HeaderBarOrderingTest.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class HeaderBarOrderingTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->form_component = new ResponsiveMenu\Form\HeaderBarOrdering;
9
+ }
10
+
11
+ public function testRendering() {
12
+ $output = $this->form_component->render(new ResponsiveMenu\Models\Option('a', '{"search": "on", "button": "off"}'));
13
+ $this->assertContains('order-option-switch order-option-switch-on', $output);
14
+ $this->assertContains('value="off" name="menu[a][button]"', $output);
15
+ $this->assertContains('value="on" name="menu[a][search]"', $output);
16
+ }
17
+
18
+ }
tests/app/Form/ImageTest.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class ImageTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->form_component = new ResponsiveMenu\Form\Image;
9
+ }
10
+
11
+ public function testRendering() {
12
+ $output = $this->form_component->render(new ResponsiveMenu\Models\Option('a', 1));
13
+ $this->assertEquals("<input type='text' class='image' id='a' name='menu[a]' value='1' />"
14
+ . "<button type='button' class='button image_button' for='a' /><i class='fa fa-upload'></i></button>", $output);
15
+ }
16
+
17
+ }
tests/app/Form/ImportTest.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class ImportTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->form_component = new ResponsiveMenu\Form\Import;
9
+ }
10
+
11
+ public function testRendering() {
12
+ $output = $this->form_component->render();
13
+ $this->assertEquals('<input type="file" name="responsive_menu_import_file" /><input type="submit" class="button submit" name="responsive_menu_import" value="Import Options" />', $output);
14
+ }
15
+
16
+ }
tests/app/Form/MenuOrderingTest.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class MenuOrderingTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->form_component = new ResponsiveMenu\Form\MenuOrdering;
9
+ }
10
+
11
+ public function testRendering() {
12
+ $output = $this->form_component->render(new ResponsiveMenu\Models\Option('a', '{"search": "on", "title": "off"}'));
13
+ $this->assertContains('menu-order-option-switch menu-order-option-switch-on', $output);
14
+ $this->assertContains('value="off" name="menu[a][title]"', $output);
15
+ $this->assertContains('value="on" name="menu[a][search]"', $output);
16
+ }
17
+ }
tests/app/Form/ResetTest.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PHPUnit\Framework\TestCase;
4
+
5
+ class ResetTest extends TestCase {
6
+
7
+ public function setUp() {
8
+ $this->form_component = new ResponsiveMenu\Form\Reset;
9
+ }
10
+
11
+ public function testRendering() {
12
+ $output = $this->form_component->render();
13
+ $this->assertEquals('<input type="submit" class="button submit" name="responsive_menu_reset" value="Reset Options" />', $output);
14
+ }
15
+
16
+ }
tests/app/Form/SelectTest.php ADDED
@@ -0,0 +1,47 @@