22b2fcf742
* Change default deb package name Changed default deb package name to `"{$name}_{$version}_{$arch}.deb"` since this is what normally would be generated. * Fix tests for default deb name The tests with default package name still expected the old version of the name. * Fixed tests Tests tried to get the Control via `$this->getControl()` which obviously failed.
106 lines
2.9 KiB
PHP
106 lines
2.9 KiB
PHP
<?php
|
|
namespace wdm\debian;
|
|
|
|
use org\bovigo\vfs\vfsStream;
|
|
|
|
class PackagerTest extends \PHPUnit_Framework_TestCase
|
|
{
|
|
public function setUp()
|
|
{
|
|
$this->object = new Packager();
|
|
}
|
|
|
|
public function testRetrieveTheBuildCommand()
|
|
{
|
|
$this->object->setOutputPath("/tmp");
|
|
|
|
$this->assertEquals("dpkg -b /tmp my.deb", $this->object->build("my.deb"));
|
|
}
|
|
|
|
public function testRetriveControlFile()
|
|
{
|
|
$control = new control\StandardFile();
|
|
$this->object->setControl($control);
|
|
|
|
$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();
|
|
|
|
$control = $this->object->getControl();
|
|
$name = $control['Package'];
|
|
$version = $control['Version'];
|
|
$arch = $control['Architecture'];
|
|
$debPackageName = "{$name}_{$version}_{$arch}.deb";
|
|
|
|
$this->assertEquals("dpkg -b vfs://root/tmp {$debPackageName}", $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();
|
|
|
|
$control = $this->object->getControl();
|
|
$name = $control['Package'];
|
|
$version = $control['Version'];
|
|
$arch = $control['Architecture'];
|
|
$debPackageName = "{$name}_{$version}_{$arch}.deb";
|
|
|
|
$this->assertEquals("dpkg -b vfs://root/tmp {$debPackageName}", $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);
|
|
}
|
|
}
|