mirror of
https://github.com/andres-montanez/Magallanes
synced 2024-06-29 02:30:05 +02:00
Added createFaclsCommand unit test, run without correct parameter test
This commit is contained in:
parent
5b2791ae99
commit
827836ccb4
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
namespace MageTest\Task\BuiltIn\Symfony2;
|
||||
|
||||
use Mage\Config;
|
||||
use Mage\Task\BuiltIn\Symfony2\ApplyFaclsTask;
|
||||
use Mage\Task\Factory;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
|
||||
|
@ -48,16 +50,60 @@ class ApplyFaclsTaskTest extends PHPUnit_Framework_TestCase
|
|||
public function test_Run_WithNoHttpUserParameter_Expect_throw_SkipException()
|
||||
{
|
||||
// Arrange
|
||||
$taskData = array(
|
||||
'name' => 'symfony2/apply-facls',
|
||||
'parameters' => array(
|
||||
'httpuser' => '',
|
||||
'localuser' => 'deployer',
|
||||
'folders' => array('var', 'web')
|
||||
),
|
||||
);
|
||||
$config = new Config();
|
||||
$config->addParameter('httpuser', '');
|
||||
$task = new ApplyFaclsTask($config);
|
||||
// Act
|
||||
$task = Factory::get($taskData, $this->config);
|
||||
$task->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @expectedException \Mage\Task\SkipException
|
||||
* @expectedExceptionMessage Parameter localuser not set.
|
||||
* @covers Mage\Task\BuiltIn\Symfony2\ApplyFaclsTask::run
|
||||
*/
|
||||
public function test_run_withNoLocalUserParameter_trow_SkipException()
|
||||
{
|
||||
// Arrange
|
||||
$config = new Config();
|
||||
$config->addParameter('httpuser', 'www-data');
|
||||
$config->addParameter('localuser', '');
|
||||
$task = new ApplyFaclsTask($config);
|
||||
// Act
|
||||
$task->run();
|
||||
}
|
||||
|
||||
public function provider_createFaclsCommand()
|
||||
{
|
||||
return [
|
||||
'no facls options' => [
|
||||
'', 'www-data', 'deployer', 'var', 'setfacl -m u:www-data:rwX -m u:deployer:rwX var'
|
||||
],
|
||||
'with facls options' => [
|
||||
'-dR', 'www-data', 'deployer', 'var', 'setfacl -dR -m u:www-data:rwX -m u:deployer:rwX var'
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @group unit
|
||||
* @dataProvider provider_createFaclsCommand
|
||||
* @covers Mage\Task\BuiltIn\Symfony2\ApplyFaclsTask::createFaclCommand
|
||||
*
|
||||
* @param string $faclOptions
|
||||
* @param string $httpUser
|
||||
* @param string $localUser
|
||||
* @param string $folder
|
||||
* @param string $expectedCommand
|
||||
*/
|
||||
public function test_createFaclsCommand($faclOptions, $httpUser, $localUser, $folder, $expectedCommand)
|
||||
{
|
||||
// Arrange
|
||||
$task = new ApplyFaclsTask($this->config);
|
||||
// Act
|
||||
$command = $task->createFaclCommand($faclOptions, $httpUser, $localUser, $folder);
|
||||
// Assert
|
||||
$this->assertEquals($expectedCommand, $command);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue