mirror of https://github.com/hauke68/Magallanes
Andrés Montañez
8 years ago
6 changed files with 305 additions and 5 deletions
@ -0,0 +1,27 @@
|
||||
<?php |
||||
namespace Mage\Tests\Command\BuiltIn\Config; |
||||
|
||||
use Mage\Command\BuiltIn\Config\DumpCommand; |
||||
use Mage\Command\AbstractCommand; |
||||
use Mage\Tests\MageTestApplication; |
||||
use Mage\Tests\Runtime\RuntimeMockup; |
||||
use Symfony\Component\Console\Tester\CommandTester; |
||||
use PHPUnit_Framework_TestCase as TestCase; |
||||
|
||||
class DumpCommandTest extends TestCase |
||||
{ |
||||
public function testConfigDumpTermination() |
||||
{ |
||||
$application = new MageTestApplication(); |
||||
$application->add(new DumpCommand()); |
||||
|
||||
/** @var AbstractCommand $command */ |
||||
$command = $application->find('config:dump'); |
||||
$command->setRuntime(new RuntimeMockup()); |
||||
|
||||
$tester = new CommandTester($command); |
||||
$tester->execute(['command' => $command->getName()]); |
||||
|
||||
$this->assertEquals($tester->getStatusCode(), 0); |
||||
} |
||||
} |
@ -0,0 +1,93 @@
|
||||
<?php |
||||
namespace Mage\Tests\Command\BuiltIn\Config; |
||||
|
||||
use Mage\Command\BuiltIn\Config\EnvironmentsCommand; |
||||
use Mage\Command\AbstractCommand; |
||||
use Mage\Tests\MageTestApplication; |
||||
use Mage\Tests\Runtime\RuntimeMockup; |
||||
use Symfony\Component\Console\Tester\CommandTester; |
||||
use PHPUnit_Framework_TestCase as TestCase; |
||||
|
||||
class EnvironmentsCommandTest extends TestCase |
||||
{ |
||||
public function testConfigDumpTermination() |
||||
{ |
||||
$application = new MageTestApplication(); |
||||
$application->add(new EnvironmentsCommand()); |
||||
|
||||
$runtime = new RuntimeMockup(); |
||||
$runtime->setConfiguration(array( |
||||
'environments' => |
||||
array( |
||||
'test' => |
||||
array( |
||||
'user' => 'tester', |
||||
'branch' => 'test', |
||||
'host_path' => '/var/www/test', |
||||
'releases' => 4, |
||||
'exclude' => |
||||
array( |
||||
0 => 'vendor', |
||||
1 => 'app/cache', |
||||
2 => 'app/log', |
||||
3 => 'web/app_dev.php', |
||||
), |
||||
'hosts' => |
||||
array( |
||||
0 => 'testhost', |
||||
), |
||||
'pre-deploy' => |
||||
array( |
||||
0 => 'git/update', |
||||
1 => 'composer/install', |
||||
2 => 'composer/generate-autoload', |
||||
), |
||||
'on-deploy' => |
||||
array( |
||||
0 => |
||||
array( |
||||
'symfony/cache-clear' => |
||||
array( |
||||
'env' => 'dev', |
||||
), |
||||
), |
||||
1 => |
||||
array( |
||||
'symfony/cache-warmup' => |
||||
array( |
||||
'env' => 'dev', |
||||
), |
||||
), |
||||
2 => |
||||
array( |
||||
'symfony/assets-install' => |
||||
array( |
||||
'env' => 'dev', |
||||
), |
||||
), |
||||
3 => |
||||
array( |
||||
'symfony/assetic-dump' => |
||||
array( |
||||
'env' => 'dev', |
||||
), |
||||
), |
||||
), |
||||
'on-release' => null, |
||||
'post-release' => null, |
||||
'post-deploy' => null, |
||||
), |
||||
), |
||||
) |
||||
); |
||||
|
||||
/** @var AbstractCommand $command */ |
||||
$command = $application->find('config:environments'); |
||||
$command->setRuntime($runtime); |
||||
|
||||
$tester = new CommandTester($command); |
||||
$tester->execute(['command' => $command->getName()]); |
||||
|
||||
$this->assertEquals($tester->getStatusCode(), 0); |
||||
} |
||||
} |
@ -0,0 +1,72 @@
|
||||
<?php |
||||
namespace Mage\Tests; |
||||
|
||||
use Mage\Utils; |
||||
use Mage\Runtime\Runtime; |
||||
use DateTime; |
||||
use PHPUnit_Framework_TestCase as TestCase; |
||||
|
||||
class UtilsTest extends TestCase |
||||
{ |
||||
public function testStageNames() |
||||
{ |
||||
$this->assertEquals(Utils::getStageName(Runtime::PRE_DEPLOY), 'Pre Deployment'); |
||||
$this->assertEquals(Utils::getStageName(Runtime::ON_DEPLOY), 'On Deployment'); |
||||
$this->assertEquals(Utils::getStageName(Runtime::POST_DEPLOY), 'Post Deployment'); |
||||
$this->assertEquals(Utils::getStageName(Runtime::ON_RELEASE), 'On Release'); |
||||
$this->assertEquals(Utils::getStageName(Runtime::POST_RELEASE), 'Post Release'); |
||||
} |
||||
|
||||
public function testReleaseDate() |
||||
{ |
||||
$releaseId = '20170102031530'; |
||||
$dateTime = Utils::getReleaseDate($releaseId); |
||||
|
||||
$this->assertTrue($dateTime instanceof DateTime); |
||||
|
||||
$this->assertEquals($dateTime->format('Y-m-d H:i:s'), '2017-01-02 03:15:30'); |
||||
} |
||||
|
||||
public function testTimeDiffs() |
||||
{ |
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-1 second'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), 'just now'); |
||||
|
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-45 seconds'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), '45 seconds ago'); |
||||
|
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-90 seconds'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), 'one minute ago'); |
||||
|
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-30 minutes'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), '30 minutes ago'); |
||||
|
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-1 hour'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), 'one hour ago'); |
||||
|
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-10 hours'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), '10 hours ago'); |
||||
|
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-1 day'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), 'one day ago'); |
||||
|
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-3 days'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), '3 days ago'); |
||||
|
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-7 days'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), 'a week ago'); |
||||
|
||||
$dateTime = new DateTime(); |
||||
$dateTime->modify('-10 days'); |
||||
$this->assertEquals(Utils::getTimeDiff($dateTime), ''); |
||||
} |
||||
} |
Loading…
Reference in new issue