ConfigTest.php in One Click Upload 7.2
File
flowphp/test/Unit/ConfigTest.php
View source
<?php
namespace Unit;
use Flow\Config;
use Flow\Request;
class ConfigTest extends FlowUnitCase {
public function testConfig_construct_config() {
$exampleConfig = array(
'tempDir' => '/some/dir',
'deleteChunksOnSave' => TRUE,
'hashNameCallback' => '\\SomeNs\\SomeClass::someMethod',
'preprocessCallback' => '\\SomeNs\\SomeClass::preProcess',
);
$config = new Config($exampleConfig);
$this
->assertSame($exampleConfig['tempDir'], $config
->getTempDir());
$this
->assertSame($exampleConfig['deleteChunksOnSave'], $config
->getDeleteChunksOnSave());
$this
->assertSame($exampleConfig['hashNameCallback'], $config
->getHashNameCallback());
$this
->assertSame($exampleConfig['preprocessCallback'], $config
->getPreprocessCallback());
}
public function testConfig_construct_default() {
$config = new Config();
$this
->assertSame('', $config
->getTempDir());
$this
->assertSame(true, $config
->getDeleteChunksOnSave());
$this
->assertSame('\\Flow\\Config::hashNameCallback', $config
->getHashNameCallback());
$this
->assertSame(null, $config
->getPreprocessCallback());
}
public function testConfig_setTempDir() {
$dir = '/some/dir';
$config = new Config();
$config
->setTempDir($dir);
$this
->assertSame($dir, $config
->getTempDir());
}
public function testConfig_setHashNameCallback() {
$callback = '\\SomeNs\\SomeClass::someMethod';
$config = new Config();
$config
->setHashNameCallback($callback);
$this
->assertSame($callback, $config
->getHashNameCallback());
}
public function testConfig_setPreprocessCallback() {
$callback = '\\SomeNs\\SomeClass::someOtherMethod';
$config = new Config();
$config
->setPreprocessCallback($callback);
$this
->assertSame($callback, $config
->getPreprocessCallback());
}
public function testConfig_setDeleteChunksOnSave() {
$config = new Config();
$config
->setDeleteChunksOnSave(false);
$this
->assertFalse($config
->getDeleteChunksOnSave());
}
public function testConfig_hashNameCallback() {
$request = new Request($this->requestArr);
$expHash = sha1($request
->getIdentifier());
$this
->assertSame($expHash, Config::hashNameCallback($request));
}
}