Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raphaeldealmeida/1235315 to your computer and use it in GitHub Desktop.
Save raphaeldealmeida/1235315 to your computer and use it in GitHub Desktop.
<?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 license@zend.com 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
* @version $Id: ProfileTest.php 23772 2011-02-28 21:35:29Z jaguarnet7 $
*/
require_once 'Zend/Tool/Project/Profile.php';
require_once 'Zend/Tool/Project/Provider/Abstract.php';
require_once 'Zend/Tool/Framework/Provider/Pretendable.php';
require_once 'Zend/Tool/Project/Provider/Controller.php';
require_once 'Zend/Tool/Project/Provider/Exception.php';
require_once 'Zend/Filter/Word/DashToCamelCase.php';
require_once 'Zend/Tool/Project/Provider/Module.php';
/**
* @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_Action
*/
class Zend_Tool_Project_Provider_ControllerTest extends PHPUnit_Framework_TestCase
{
protected $_projectDirectory = null;
protected $_projectProfileFile = null;
/**
* @var Zend_Tool_Project_Profile
*/
protected $_standardProfileFromData = null;
public function setup()
{
$this->_projectDirectory = dirname(__FILE__) . '/../_files/project1/';
$this->_projectProfileFile = dirname(__FILE__) . '/../_files/.zfproject.xml.orig';
$this->_removeProjectFiles();
Zend_Tool_Project_Context_Repository::resetInstance();
$contextRegistry = Zend_Tool_Project_Context_Repository::getInstance();
$contextRegistry->addContextsFromDirectory(dirname(__FILE__) . '/../../../../../library/Zend/Tool/Project/Context/Zf/', 'Zend_Tool_Project_Context_Zf_');
$this->_standardProfileFromData = new Zend_Tool_Project_Profile();
$this->_standardProfileFromData->setAttribute('profileData', file_get_contents($this->_projectProfileFile));
$this->_standardProfileFromData->setAttribute('projectDirectory', $this->_projectDirectory);
}
public function teardown()
{
$this->_removeProjectFiles();
}
/**
*
* @group ZF-8305
*/
public function testCreateControllerWithoutModule() {
$this->_standardProfileFromData->loadFromData();
foreach ($this->_standardProfileFromData->getIterator() as $resource) {
$resource->getContext()->create();
}
$providerController = new Zend_Tool_Project_Provider_Controller();
$providerController->createResource($this->_standardProfileFromData, 'TestController');
}
protected function _removeProjectFiles()
{
$rdi = new RecursiveDirectoryIterator($this->_projectDirectory);
foreach (new RecursiveIteratorIterator($rdi, RecursiveIteratorIterator::CHILD_FIRST) as $dirIteratorItem) {
$basename = $dirIteratorItem->getBasename();
if (stristr($dirIteratorItem->getPathname(), '.svn')
|| '.' === $basename
|| '..' === $basename)
{
continue;
}
if ($dirIteratorItem->isDir()) {
rmdir($dirIteratorItem->getPathname());
} elseif ($dirIteratorItem->isFile()) {
unlink($dirIteratorItem->getPathname());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment