mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 09:12:51 +01:00
Add support tests
This commit is contained in:
parent
be23ad3c4e
commit
3f52da4a20
@ -51,7 +51,7 @@ function array_merge_alternate(array $original, array $override)
|
||||
$original[$key] = array_unique(array_merge($original[$key], $value));
|
||||
} else {
|
||||
// Merge all other arrays
|
||||
$original[$key] = Config::merge($original[$key], $value);
|
||||
$original[$key] = array_merge_alternate($original[$key], $value);
|
||||
}
|
||||
} else {
|
||||
// Simply add new key/value
|
||||
|
54
test/src/Support/HelpersTest.php
Normal file
54
test/src/Support/HelpersTest.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/* (c) Anton Medvedev <anton@medv.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Deployer\Support;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class HelpersTest extends TestCase
|
||||
{
|
||||
public function testArrayFlatten()
|
||||
{
|
||||
self::assertEquals(['a', 'b', 'c'], array_flatten(['a', ['b', 'key' => ['c']]]));
|
||||
}
|
||||
|
||||
public function testArrayMergeAlternate()
|
||||
{
|
||||
$config = [
|
||||
'one',
|
||||
'two' => 2,
|
||||
'nested' => [],
|
||||
];
|
||||
|
||||
$config = array_merge_alternate($config, [
|
||||
'two' => 20,
|
||||
'nested' => [
|
||||
'first',
|
||||
],
|
||||
]);
|
||||
|
||||
$config = array_merge_alternate($config, [
|
||||
'nested' => [
|
||||
'second',
|
||||
],
|
||||
]);
|
||||
|
||||
$config = array_merge_alternate($config, [
|
||||
'extra'
|
||||
]);
|
||||
|
||||
self::assertEquals([
|
||||
'one',
|
||||
'two' => 20,
|
||||
'nested' => [
|
||||
'first',
|
||||
'second',
|
||||
],
|
||||
'extra',
|
||||
], $config);
|
||||
}
|
||||
}
|
27
test/src/Support/ProxyTest.php
Normal file
27
test/src/Support/ProxyTest.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
/* (c) Anton Medvedev <anton@medv.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Deployer\Support;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ProxyTest extends TestCase
|
||||
{
|
||||
public function testProxy()
|
||||
{
|
||||
$mock = self::getMockBuilder('stdClass')
|
||||
->setMethods(['foo'])
|
||||
->getMock();
|
||||
$mock
|
||||
->expects(self::once())
|
||||
->method('foo')
|
||||
->with('a', 'b');
|
||||
|
||||
$proxy = new Proxy([$mock]);
|
||||
$proxy->foo('a', 'b');
|
||||
}
|
||||
}
|
@ -5,9 +5,8 @@
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Deployer\Utility;
|
||||
namespace Deployer\Support;
|
||||
|
||||
use Deployer\Support\Unix;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UnixTest extends TestCase
|
21
test/src/Utility/ProcessRunnerTest.php
Normal file
21
test/src/Utility/ProcessRunnerTest.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/* (c) Anton Medvedev <anton@medv.io>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Deployer\Utility;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Output\Output;
|
||||
|
||||
class ProcessRunnerTest extends TestCase
|
||||
{
|
||||
public function testRun()
|
||||
{
|
||||
$output = $this->createMock(Output::class);
|
||||
$pr = new ProcessRunner();
|
||||
self::assertEquals('true', $pr->run($output, 'hostname', 'printf "true"'));
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user