|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2022 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\Controller\Jobs; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
class BaseTest extends \PHPUnit\Framework\TestCase |
|
13
|
|
|
{ |
|
14
|
|
|
private $object; |
|
15
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
protected function setUp() : void |
|
18
|
|
|
{ |
|
19
|
|
|
$context = \TestHelperJobs::context(); |
|
20
|
|
|
$aimeos = \TestHelperJobs::getAimeos(); |
|
21
|
|
|
|
|
22
|
|
|
$context->config()->set( 'controller/jobs/to-email', 'me@localhost' ); |
|
23
|
|
|
|
|
24
|
|
|
$this->object = $this->getMockForAbstractClass( '\Aimeos\Controller\Jobs\Base', [$context, $aimeos] ); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
protected function tearDown() : void |
|
29
|
|
|
{ |
|
30
|
|
|
unset( $this->object ); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
public function testVal() |
|
35
|
|
|
{ |
|
36
|
|
|
$method = $this->access( 'val' ); |
|
37
|
|
|
|
|
38
|
|
|
$this->assertEquals( 'value', $method->invokeArgs( $this->object, [['key' => ' value '], 'key', 'def'] ) ); |
|
39
|
|
|
$this->assertEquals( 'def', $method->invokeArgs( $this->object, [['key' => ' '], 'key', 'def'] ) ); |
|
40
|
|
|
$this->assertEquals( 'def', $method->invokeArgs( $this->object, [[], 'key', 'def'] ) ); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
public function testMail() |
|
45
|
|
|
{ |
|
46
|
|
|
$result = $this->access( 'mail' )->invokeArgs( $this->object, ['me@localhost', 'test'] ); |
|
47
|
|
|
$this->assertSame( $this->object, $result ); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
protected function access( $name ) |
|
52
|
|
|
{ |
|
53
|
|
|
$class = new \ReflectionClass( \Aimeos\Controller\Jobs\Base::class ); |
|
54
|
|
|
$method = $class->getMethod( $name ); |
|
55
|
|
|
$method->setAccessible( true ); |
|
56
|
|
|
|
|
57
|
|
|
return $method; |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|