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 / Services / OptionsServiceTest.php

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

60 lines 2.6 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\Services\OptionService;
5
6 class OptionsServiceTest extends TestCase {
7
8 public function setUp() {
9 $this->repository = $this->createMock('ResponsiveMenu\Repositories\OptionRepository');
10 $this->factory = $this->createMock('ResponsiveMenu\Factories\OptionFactory');
11 $this->translator = $this->createMock('ResponsiveMenu\Translation\Translator');
12 $this->scripts_builder = $this->createMock('ResponsiveMenu\Filesystem\ScriptsBuilder');
13
14 $this->service = new OptionService($this->repository, $this->factory, $this->translator, $this->scripts_builder);
15 }
16
17 public function testCombiningBasicOptions() {
18 $this->assertSame(['one' => 1, 'two' => 'two'], $this->service->combineOptions(['one' => 1],['two' => 'two']));
19 }
20
21 public function testCombiningStringZeroOptions() {
22 $this->assertSame(['one' => '0'], $this->service->combineOptions(['one' => 'default'],['one' => '0']));
23 }
24
25 public function testCombiningIntegerZeroOptions() {
26 $this->assertSame(['one' => 0], $this->service->combineOptions(['one' => 'default'],['one' => 0]));
27 }
28
29 public function testOverwritingDefaultOptionValue() {
30 $this->assertSame(['one' => 'updated'], $this->service->combineOptions(['one' => 'default'],['one' => 'updated']));
31 }
32
33 public function testRepositoryReturn() {
34 $this->repository->method('all')->willReturn('a');
35 $this->assertEquals('a', $this->service->all());
36 }
37
38 public function testBuildPostArray() {
39 $this->repository->method('buildFromArray')->willReturn('a');
40 $this->assertEquals('a', $this->service->buildFromPostArray([]));
41 }
42
43 public function testUpdateOptions() {
44 $this->repository->method('all')->willReturn(new ResponsiveMenu\Collections\OptionsCollection);
45 $this->repository->method('update')->willReturn('a');
46 $this->factory->method('build')->willReturn(new ResponsiveMenu\Models\Option('a', 1));
47 $this->assertInstanceOf('ResponsiveMenu\Collections\OptionsCollection', $this->service->updateOptions(['a' => 1]));
48 }
49
50 public function testCreateOptions() {
51 $collection = new ResponsiveMenu\Collections\OptionsCollection;
52 $collection->add(new ResponsiveMenu\Models\Option('external_files', 'on'));
53 $this->repository->method('all')->willReturn($collection);
54 $this->repository->method('create')->willReturn('a');
55 $this->factory->method('build')->willReturn(new ResponsiveMenu\Models\Option('a', 1));
56 $this->assertInstanceOf('ResponsiveMenu\Collections\OptionsCollection', $this->service->createOptions(['a' => 1]));
57 }
58
59 }
60