Skip to content

Commit

Permalink
Merge branch 'hotfix/ZF2-11/tool_framework_client_storage' of https:/…
Browse files Browse the repository at this point in the history
…/github.com/sasezaki/zf2 into hotfix/zf2-11
  • Loading branch information
weierophinney committed Jul 7, 2011
2 parents b06b206 + 4934fea commit b3dc5b4
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 7 deletions.
6 changes: 0 additions & 6 deletions library/Zend/Tool/Framework/Client/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
namespace Zend\Tool\Framework\Client;

/**
* @uses \Zend\Loader
* @uses \Zend\Tool\Framework\Client\Storage\Adapter
* @category Zend
* @package Zend_Tool
Expand All @@ -49,11 +48,6 @@ public function __construct($options = array())

public function setAdapter($adapter)
{
if (is_string($adapter)) {
$storageAdapterClass = 'Zend\Tool\Framework\Client\Storage\\' . ucfirst($adapter);
\Zend\Loader::loadClass($storageAdapterClass);
$adapter = new $storageAdapterClass();
}
$this->_adapter = $adapter;
}

Expand Down
2 changes: 1 addition & 1 deletion library/Zend/Tool/Framework/Client/Storage/Directory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Directory implements Adapter
public function __construct($directoryPath)
{
if (!file_exists($directoryPath)) {
throw new \Zend\Tool\Framework\Client\Exception(__CLASS__ . ': the supplied directory does not exist');
throw new Exception\UnexpectedValueException(__CLASS__ . ': the supplied directory does not exist');
}
$this->_directoryPath = $directoryPath;
}
Expand Down
35 changes: 35 additions & 0 deletions library/Zend/Tool/Framework/Client/Storage/Exception.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Tool
* @subpackage Framework
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace Zend\Tool\Framework\Client\Storage;

/**
* @category Zend
* @package Zend_Tool
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
interface Exception
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Zend\Tool\Framework\Client\Storage\Exception;

class UnexpectedValueException
extends \UnexpectedValueException
implements \Zend\Tool\Framework\Client\Storage\Exception
{
}
51 changes: 51 additions & 0 deletions tests/Zend/Tool/Framework/Client/Storage/DirectoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Tool
* @subpackage UnitTests
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace ZendTest\Tool\Framework\Client;
use Zend\Tool\Framework\Client\Storage\Directory,
Zend\Tool\Framework\Client\Storage\Exception\UnexpectedValueException;

/**
* @category Zend
* @package Zend_Tool
* @subpackage UnitTests
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*
* @group Zend_Tool
* @group Zend_Tool_Framework
* @group Zend_Tool_Framework_Client
* @group Zend_Tool_Framework_Client_Storage
*/
class DirectoryTest extends \PHPUnit_Framework_TestCase
{
public function testNonExistsDirectory()
{
try {
$directory = new Directory(__DIR__.DIRECTORY_SEPARATOR.'nonexists');
$this->fail('RuntimeException was expected but not thrown');
} catch (UnexpectedValueException $ue) {
}
}
}
67 changes: 67 additions & 0 deletions tests/Zend/Tool/Framework/Client/StorageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Tool
* @subpackage UnitTests
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

/**
* @namespace
*/
namespace ZendTest\Tool\Framework\Client;
use Zend\Tool\Framework\Client\Storage;

/**
* @category Zend
* @package Zend_Tool
* @subpackage UnitTests
* @copyright Copyright (c) 2005-2011 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*
* @group Zend_Tool
* @group Zend_Tool_Framework
* @group Zend_Tool_Framework_Client
*/
class StorageTest extends \PHPUnit_Framework_TestCase
{
/**
* @var Zend\Tool\Framework\Client\Storage
*/
protected $storage = null;

public function setup()
{
$this->storage = new Storage();
}

public function getStorageDirectory()
{
return __DIR__.DIRECTORY_SEPARATOR.'_files'. DIRECTORY_SEPARATOR .'storagedirectory';
}

public function testNoAdapterStorageIsNotEnabled()
{
$this->assertFalse($this->storage->isEnabled());
}

public function testPassingArrayToConstructor()
{
$directory = new Storage\Directory($this->getStorageDirectory());
$storage = new Storage(array('adapter' => $directory));
$this->assertTrue($storage->isEnabled());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit b3dc5b4

Please sign in to comment.