| 1 |
<?php |
| 2 |
|
| 3 |
use PHPUnit\Framework\TestCase; |
| 4 |
|
| 5 |
class JsMapperTest extends TestCase { |
| 6 |
|
| 7 |
public function setUp() { |
| 8 |
$this->collection = new ResponsiveMenu\Collections\OptionsCollection; |
| 9 |
$this->collection->add(new ResponsiveMenu\Models\Option('animation_speed', 5)); |
| 10 |
$this->collection->add(new ResponsiveMenu\Models\Option('button_click_trigger', 'a')); |
| 11 |
$this->collection->add(new ResponsiveMenu\Models\Option('active_arrow_image', 'a')); |
| 12 |
$this->collection->add(new ResponsiveMenu\Models\Option('active_arrow_image_alt', 'n')); |
| 13 |
$this->collection->add(new ResponsiveMenu\Models\Option('inactive_arrow_image', 'b')); |
| 14 |
$this->collection->add(new ResponsiveMenu\Models\Option('inactive_arrow_image_alt', 'm')); |
| 15 |
$this->collection->add(new ResponsiveMenu\Models\Option('breakpoint', 'c')); |
| 16 |
$this->collection->add(new ResponsiveMenu\Models\Option('button_click_trigger', 'd')); |
| 17 |
$this->collection->add(new ResponsiveMenu\Models\Option('animation_type', 'e')); |
| 18 |
$this->collection->add(new ResponsiveMenu\Models\Option('menu_appear_from', 'f')); |
| 19 |
$this->collection->add(new ResponsiveMenu\Models\Option('page_wrapper', 'g')); |
| 20 |
$this->collection->add(new ResponsiveMenu\Models\Option('accordion_animation', 'h')); |
| 21 |
$this->collection->add(new ResponsiveMenu\Models\Option('menu_close_on_body_click', 'i')); |
| 22 |
$this->collection->add(new ResponsiveMenu\Models\Option('menu_close_on_link_click', 'j')); |
| 23 |
$this->collection->add(new ResponsiveMenu\Models\Option('menu_item_click_to_trigger_submenu', 'k')); |
| 24 |
$this->collection->add(new ResponsiveMenu\Models\Option('button_push_with_animation', 'l')); |
| 25 |
|
| 26 |
$this->mapper = new ResponsiveMenu\Mappers\JsMapper; |
| 27 |
} |
| 28 |
|
| 29 |
public function testOutput() { |
| 30 |
$mapped = $this->mapper->map($this->collection); |
| 31 |
$this->assertContains('animationSpeed: 5000', $mapped); |
| 32 |
$this->assertContains("trigger: 'd'", $mapped); |
| 33 |
$this->assertContains('breakpoint: c', $mapped); |
| 34 |
$this->assertContains("pushButton: 'l'", $mapped); |
| 35 |
$this->assertContains("animationType: 'e'", $mapped); |
| 36 |
$this->assertContains("animationSide: 'f'", $mapped); |
| 37 |
$this->assertContains("pageWrapper: 'g'", $mapped); |
| 38 |
$this->assertContains("accordion: 'h'", $mapped); |
| 39 |
$this->assertContains("closeOnBodyClick: 'i'", $mapped); |
| 40 |
$this->assertContains("closeOnLinkClick: 'j'", $mapped); |
| 41 |
$this->assertContains("itemTriggerSubMenu: 'k'", $mapped); |
| 42 |
$this->assertContains('alt="m"', $mapped); |
| 43 |
$this->assertContains('alt="n"', $mapped); |
| 44 |
} |
| 45 |
|
| 46 |
public function testDefaultAnimationSpeed() { |
| 47 |
$collection = new ResponsiveMenu\Collections\OptionsCollection; |
| 48 |
$collection->add(new ResponsiveMenu\Models\Option('active_arrow_image', 'a')); |
| 49 |
$collection->add(new ResponsiveMenu\Models\Option('active_arrow_image_alt', 'c')); |
| 50 |
$collection->add(new ResponsiveMenu\Models\Option('inactive_arrow_image', 'b')); |
| 51 |
$collection->add(new ResponsiveMenu\Models\Option('inactive_arrow_image_alt', 'd')); |
| 52 |
$mapper = new ResponsiveMenu\Mappers\JsMapper; |
| 53 |
$mapped = $this->mapper->map($collection); |
| 54 |
$this->assertContains('animationSpeed: 500', $mapped); |
| 55 |
$this->assertContains('alt="c"', $mapped); |
| 56 |
$this->assertContains('alt="d"', $mapped); |
| 57 |
} |
| 58 |
|
| 59 |
} |
| 60 |
|