Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 348ec08

Browse files
committed
Implemented more methods in AbstractBaseModule
Extending classes now only need to implement `setup()` and `run()`.
1 parent 362858d commit 348ec08

2 files changed

Lines changed: 48 additions & 6 deletions

File tree

‎src/Module/AbstractBaseModule.php‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,13 @@
22

33
namespace RebelCode\Modular\Module;
44

5+
use Dhii\Data\Container\NormalizeContainerCapableTrait;
6+
use Dhii\Exception\CreateInvalidArgumentExceptionCapableTrait;
7+
use Dhii\I18n\StringTranslatingTrait;
58
use Dhii\Modular\Module\DependenciesAwareInterface;
69
use Dhii\Modular\Module\ModuleInterface;
10+
use Dhii\Util\Normalization\NormalizeIterableCapableTrait;
11+
use Dhii\Util\Normalization\NormalizeStringCapableTrait;
712

813
/**
914
* Common base functionality for modules.
@@ -23,4 +28,39 @@ abstract class AbstractBaseModule implements
2328
_getKey as public getKey;
2429
_getDependencies as public getDependencies;
2530
}
31+
32+
/*
33+
* Provides string normalization functionality.
34+
*
35+
* @since [*next-version*]
36+
*/
37+
use NormalizeStringCapableTrait;
38+
39+
/*
40+
* Provides iterable normalization functionality.
41+
*
42+
* @since [*next-version*]
43+
*/
44+
use NormalizeIterableCapableTrait;
45+
46+
/*
47+
* Provides container normalization functionality.
48+
*
49+
* @since [*next-version*]
50+
*/
51+
use NormalizeContainerCapableTrait;
52+
53+
/*
54+
* Provides functionality for creating invalid-argument exceptions.
55+
*
56+
* @since [*next-version*]
57+
*/
58+
use CreateInvalidArgumentExceptionCapableTrait;
59+
60+
/*
61+
* Provides string translating functionality.
62+
*
63+
* @since [*next-version*]
64+
*/
65+
use StringTranslatingTrait;
2666
}

‎test/functional/Module/AbstractBaseModuleTest.php‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,14 @@ class AbstractBaseModuleTest extends TestCase
2929
*/
3030
public function createInstance()
3131
{
32-
$mock = $this->getMockForAbstractClass(static::TEST_SUBJECT_CLASSNAME);
32+
$mock = $this->getMockBuilder(static::TEST_SUBJECT_CLASSNAME)
33+
->setMethods(
34+
[
35+
'setup',
36+
'run',
37+
]
38+
)
39+
->getMockForAbstractClass();
3340

3441
return $mock;
3542
}
@@ -89,11 +96,6 @@ public function testGetDependencies()
8996
uniqid('dep-'),
9097
];
9198

92-
$subject->expects($this->once())
93-
->method('_normalizeIterable')
94-
->with($deps)
95-
->willReturn($deps);
96-
9799
$reflect->_setDependencies($deps);
98100

99101
$this->assertEquals($deps, $subject->getDependencies(), 'Set and retrieved dependencies are not the same.');

0 commit comments

Comments
 (0)