Added functional test
* The packager will throws exceptions when the output folder exists
This commit is contained in:
parent
248c14d301
commit
9ccde2227a
|
@ -19,7 +19,8 @@
|
||||||
"php": ">=5.3.3"
|
"php": ">=5.3.3"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~4"
|
"phpunit/phpunit": "~4",
|
||||||
|
"mikey179/vfsStream": "1.4.*"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
|
|
92
composer.lock
generated
92
composer.lock
generated
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"_readme": [
|
"_readme": [
|
||||||
"This file locks the dependencies of your project to a known state",
|
"This file locks the dependencies of your project to a known state",
|
||||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"hash": "42aa3f85b9b2e12726c3a920256505a0",
|
"hash": "452e33232d90b29107daa9bb4740b3ea",
|
||||||
"packages": [],
|
"packages": [],
|
||||||
"packages-dev": [
|
"packages-dev": [
|
||||||
{
|
{
|
||||||
|
@ -61,6 +61,44 @@
|
||||||
],
|
],
|
||||||
"time": "2014-10-13 12:58:55"
|
"time": "2014-10-13 12:58:55"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "mikey179/vfsStream",
|
||||||
|
"version": "v1.4.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/mikey179/vfsStream.git",
|
||||||
|
"reference": "61b12172292cf539685507aa65b076c1530e83c1"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/mikey179/vfsStream/zipball/61b12172292cf539685507aa65b076c1530e83c1",
|
||||||
|
"reference": "61b12172292cf539685507aa65b076c1530e83c1",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.4.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-0": {
|
||||||
|
"org\\bovigo\\vfs\\": "src/main/php"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD"
|
||||||
|
],
|
||||||
|
"homepage": "http://vfs.bovigo.org/",
|
||||||
|
"time": "2014-09-14 10:18:53"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "phpdocumentor/reflection-docblock",
|
"name": "phpdocumentor/reflection-docblock",
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
|
@ -112,16 +150,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpspec/prophecy",
|
"name": "phpspec/prophecy",
|
||||||
"version": "1.4.0",
|
"version": "v1.4.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpspec/prophecy.git",
|
"url": "https://github.com/phpspec/prophecy.git",
|
||||||
"reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5"
|
"reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5",
|
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373",
|
||||||
"reference": "8724cd239f8ef4c046f55a3b18b4d91cc7f3e4c5",
|
"reference": "3132b1f44c7bf2ec4c7eb2d3cb78fdeca760d373",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -168,20 +206,20 @@
|
||||||
"spy",
|
"spy",
|
||||||
"stub"
|
"stub"
|
||||||
],
|
],
|
||||||
"time": "2015-03-27 19:31:25"
|
"time": "2015-04-27 22:15:08"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "2.0.16",
|
"version": "2.0.17",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||||
"reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c"
|
"reference": "c4e8e7725e351184a76544634855b8a9c405a6e3"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/934fd03eb6840508231a7f73eb8940cf32c3b66c",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c4e8e7725e351184a76544634855b8a9c405a6e3",
|
||||||
"reference": "934fd03eb6840508231a7f73eb8940cf32c3b66c",
|
"reference": "c4e8e7725e351184a76544634855b8a9c405a6e3",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -230,7 +268,7 @@
|
||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2015-04-11 04:35:00"
|
"time": "2015-05-25 05:11:59"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-file-iterator",
|
"name": "phpunit/php-file-iterator",
|
||||||
|
@ -418,16 +456,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit",
|
"name": "phpunit/phpunit",
|
||||||
"version": "4.6.4",
|
"version": "4.6.7",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||||
"reference": "163232991e652e6efed2f8470326fffa61e848e2"
|
"reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/163232991e652e6efed2f8470326fffa61e848e2",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/57bf06dd4eebe2a5ced79a8de71509e7d5c18b25",
|
||||||
"reference": "163232991e652e6efed2f8470326fffa61e848e2",
|
"reference": "57bf06dd4eebe2a5ced79a8de71509e7d5c18b25",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -486,7 +524,7 @@
|
||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
"time": "2015-04-11 05:23:21"
|
"time": "2015-05-25 05:18:18"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit-mock-objects",
|
"name": "phpunit/phpunit-mock-objects",
|
||||||
|
@ -916,17 +954,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/yaml",
|
"name": "symfony/yaml",
|
||||||
"version": "v2.6.6",
|
"version": "v2.6.7",
|
||||||
"target-dir": "Symfony/Component/Yaml",
|
"target-dir": "Symfony/Component/Yaml",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Yaml.git",
|
"url": "https://github.com/symfony/Yaml.git",
|
||||||
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4"
|
"reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Yaml/zipball/174f009ed36379a801109955fc5a71a49fe62dd4",
|
"url": "https://api.github.com/repos/symfony/Yaml/zipball/f157ab074e453ecd4c0fa775f721f6e67a99d9e2",
|
||||||
"reference": "174f009ed36379a801109955fc5a71a49fe62dd4",
|
"reference": "f157ab074e453ecd4c0fa775f721f6e67a99d9e2",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -951,18 +989,18 @@
|
||||||
"MIT"
|
"MIT"
|
||||||
],
|
],
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
|
||||||
"name": "Symfony Community",
|
|
||||||
"homepage": "http://symfony.com/contributors"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "Fabien Potencier",
|
"name": "Fabien Potencier",
|
||||||
"email": "fabien@symfony.com"
|
"email": "fabien@symfony.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Symfony Yaml Component",
|
"description": "Symfony Yaml Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "https://symfony.com",
|
||||||
"time": "2015-03-30 15:54:10"
|
"time": "2015-05-02 15:18:45"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
namespace wdm\debian;
|
namespace wdm\debian;
|
||||||
|
|
||||||
|
use RuntimeException;
|
||||||
use wdm\debian\control\StandardFile;
|
use wdm\debian\control\StandardFile;
|
||||||
|
|
||||||
class Packager
|
class Packager
|
||||||
|
@ -109,13 +110,14 @@ class Packager
|
||||||
$iterator = new \DirectoryIterator($this->getOutputPath());
|
$iterator = new \DirectoryIterator($this->getOutputPath());
|
||||||
foreach ($iterator as $path) {
|
foreach ($iterator as $path) {
|
||||||
if ($path != '.' && $path != '..') {
|
if ($path != '.' && $path != '..') {
|
||||||
echo "OUTPUT DIRECTORY MUST BE EMPTY! Something exists, exit immediately!" . PHP_EOL;
|
throw new RuntimeException("OUTPUT DIRECTORY MUST BE EMPTY! Something exists, exit immediately!");
|
||||||
exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mkdir($this->getOutputPath(), 0777);
|
if (!file_exists($this->getOutputPath())) {
|
||||||
|
mkdir($this->getOutputPath(), 0777);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->_mountPoints as $path => $dest) {
|
foreach ($this->_mountPoints as $path => $dest) {
|
||||||
$this->_pathToPath($path, $this->getOutputPath() . DIRECTORY_SEPARATOR . $dest);
|
$this->_pathToPath($path, $this->getOutputPath() . DIRECTORY_SEPARATOR . $dest);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
namespace wdm\debian;
|
namespace wdm\debian;
|
||||||
|
|
||||||
|
use org\bovigo\vfs\vfsStream;
|
||||||
|
|
||||||
class PackagerTest extends \PHPUnit_Framework_TestCase
|
class PackagerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
|
@ -22,4 +24,70 @@ class PackagerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertSame($control, $this->object->getControl());
|
$this->assertSame($control, $this->object->getControl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException RuntimeException
|
||||||
|
* @expectedExceptionMessage OUTPUT DIRECTORY MUST BE EMPTY! Something exists, exit immediately!
|
||||||
|
*/
|
||||||
|
public function testOutputFolderIsNotEmpty()
|
||||||
|
{
|
||||||
|
$root = vfsStream::setup('root');
|
||||||
|
|
||||||
|
mkdir(vfsStream::url('root/tmp'));
|
||||||
|
file_put_contents(vfsStream::url('root/tmp/ciao.txt'), "ciao");
|
||||||
|
|
||||||
|
$this->object->setOutputPath(vfsStream::url('root/tmp'));
|
||||||
|
|
||||||
|
$control = new control\StandardFile();
|
||||||
|
$this->object->setControl($control);
|
||||||
|
|
||||||
|
$this->object->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testOutputFolderExistsButIsEmpty()
|
||||||
|
{
|
||||||
|
$root = vfsStream::setup('root');
|
||||||
|
|
||||||
|
mkdir(vfsStream::url('root/tmp'));
|
||||||
|
|
||||||
|
$this->object->setOutputPath(vfsStream::url('root/tmp'));
|
||||||
|
|
||||||
|
$control = new control\StandardFile();
|
||||||
|
$this->object->setControl($control);
|
||||||
|
|
||||||
|
$this->object->run();
|
||||||
|
$command = $this->object->build();
|
||||||
|
|
||||||
|
$this->assertEquals("dpkg -b vfs://root/tmp tmp.deb", $command);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCreateDebWhenOutputFolderIsMissing()
|
||||||
|
{
|
||||||
|
$root = vfsStream::setup('root');
|
||||||
|
|
||||||
|
$this->object->setOutputPath(vfsStream::url('root/tmp'));
|
||||||
|
|
||||||
|
$control = new control\StandardFile();
|
||||||
|
$this->object->setControl($control);
|
||||||
|
|
||||||
|
$this->object->run();
|
||||||
|
$command = $this->object->build();
|
||||||
|
|
||||||
|
$this->assertEquals("dpkg -b vfs://root/tmp tmp.deb", $command);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCreateDebPackageWithAnotherName()
|
||||||
|
{
|
||||||
|
$root = vfsStream::setup('root');
|
||||||
|
|
||||||
|
$this->object->setOutputPath(vfsStream::url('root/tmp'));
|
||||||
|
|
||||||
|
$control = new control\StandardFile();
|
||||||
|
$this->object->setControl($control);
|
||||||
|
|
||||||
|
$this->object->run();
|
||||||
|
$command = $this->object->build("myname.deb");
|
||||||
|
|
||||||
|
$this->assertEquals("dpkg -b vfs://root/tmp myname.deb", $command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue