Ejemplo n.º 1
0
 public function setUp()
 {
     App::build(array('View' => array(App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'View' . DS), 'Plugin' => array(App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), App::RESET);
     $this->path = App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'webroot' . DS;
     $this->file = $this->path . 'css' . DS . 'default.css';
     $this->Asset = new CssAsset('css/default.css', $this->file, $this->path);
 }
 /**
  * admin_edit method
  *
  * @param int $id
  * @return void
  */
 public function admin_edit($id = null)
 {
     $this->InvoicesCounter->recursive = -1;
     if (!empty($this->data)) {
         if ($this->InvoicesCounter->save($this->data)) {
             Cache::delete('LilInvoices.sidebarCounters', 'Lil');
             $this->setFlash(__d('lil_invoices', 'Counter has been saved.'));
             $this->doRedirect(array('action' => 'index'));
         } else {
             $this->setFlash(__d('lil_invoices', 'Please verify that the information is correct.'), 'error');
         }
     } else {
         if (!empty($id)) {
             $this->data = $this->InvoicesCounter->read(null, $id);
         }
     }
     $this->setupRedirect();
     $layouts = array();
     $files = new DirectoryIterator(App::pluginPath('LilInvoices') . 'View' . DS . 'Reports');
     foreach ($files as $item) {
         if ($item->isFile() && ($basename = $item->getBasename('.ctp'))) {
             $layouts[$basename] = $basename;
         }
     }
     $this->set(compact('layouts'));
 }
Ejemplo n.º 3
0
 /**
  * Loads a file from app/tests/config/configure_file.php or app/plugins/PLUGIN/tests/config/configure_file.php
  *
  * Config file variables should be formated like:
  *  $config['name'] = 'value';
  * These will be used to create dynamic Configure vars.
  *
  *
  * @param string $fileName name of file to load, extension must be .php and only the name
  *     should be used, not the extenstion.
  * @param string $type Type of config file being loaded. If equal to 'app' core config files will be use.
  *    if $type == 'pluginName' that plugins tests/config files will be loaded.
  * @return mixed false if file not found, void if load successful
  */
 public function loadConfig($fileName, $type = 'app')
 {
     $found = false;
     if ($type == 'app') {
         $folder = APP . 'tests' . DS . 'config' . DS;
     } else {
         $folder = App::pluginPath($type);
         if (!empty($folder)) {
             $folder .= 'tests' . DS . 'config' . DS;
         } else {
             return false;
         }
     }
     if (file_exists($folder . $fileName . '.php')) {
         include $folder . $fileName . '.php';
         $found = true;
     }
     if (!$found) {
         return false;
     }
     if (!isset($config)) {
         $error = __("AppTestCase::load() - no variable \$config found in %s.php");
         trigger_error(sprintf($error, $fileName), E_USER_WARNING);
         return false;
     }
     return $config;
 }
Ejemplo n.º 4
0
 function setUp()
 {
     parent::setUp();
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->_testPath = $this->_pluginPath . 'Test/test_files/css/';
     $this->filter = new TimestampImage();
 }
Ejemplo n.º 5
0
 /**
  * Read a config file and return its contents.
  *
  * Files with `.` in the name will be treated as values in plugins.  Instead of reading from
  * the initialized path, plugin keys will be located using App::pluginPath().
  *
  * @param string $key The identifier to read from.  If the key has a . it will be treated
  *  as a plugin prefix.
  * @return array Parsed configuration values.
  * @throws ConfigureException when files don't exist or they don't contain `$config`.
  *  Or when files contain '..' as this could lead to abusive reads.
  */
 public function read($key)
 {
     if (strpos($key, '..') !== false) {
         throw new ConfigureException(__d('cake_dev', 'Cannot load configuration files with ../ in them.'));
     }
     if (substr($key, -4) === '.php') {
         $key = substr($key, 0, -4);
     }
     list($plugin, $key) = pluginSplit($key);
     if ($plugin) {
         $file = App::pluginPath($plugin) . 'Config' . DS . $key;
     } else {
         $file = $this->_path . $key;
     }
     $file .= '.php';
     if (!is_file($file)) {
         if (!is_file(substr($file, 0, -4))) {
             throw new ConfigureException(__d('cake_dev', 'Could not load configuration files: %s or %s', $file, substr($file, 0, -4)));
         }
     }
     include $file;
     if (!isset($config)) {
         throw new ConfigureException(sprintf(__d('cake_dev', 'No variable $config found in %s.php'), $file));
     }
     return $config;
 }
 /**
  * 	All SnatzAPISource tests suite
  *
  * @return PHPUnit_Framework_TestSuite the instance of PHPUnit_Framework_TestSuite
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All SMSFlySource Tests');
     $basePath = App::pluginPath('SMSFlySource') . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectoryRecursive($basePath);
     return $suite;
 }
Ejemplo n.º 7
0
 public function startTest($method)
 {
     parent::startTest($method);
     $this->path = App::pluginPath('upload') . 'tests' . DS . 'images' . DS;
     $this->source = $this->path . 'panda.jpg';
     $this->Resize = new Resize('php', $this->source);
 }
Ejemplo n.º 8
0
 /**
  * Run Migrations and add data in table
  *
  * @return If migrations have succeeded
  */
 public function setupDatabase()
 {
     $plugins = Configure::read('Core.corePlugins');
     $migrationsSucceed = true;
     foreach ($plugins as $plugin) {
         $migrationsSucceed = $this->runMigrations($plugin);
         if (!$migrationsSucceed) {
             break;
         }
     }
     if ($migrationsSucceed) {
         $path = App::pluginPath('Install') . DS . 'Config' . DS . 'Data' . DS;
         $dataObjects = App::objects('class', $path);
         foreach ($dataObjects as $data) {
             include $path . $data . '.php';
             $classVars = get_class_vars($data);
             $modelAlias = substr($data, 0, -4);
             $table = $classVars['table'];
             $records = $classVars['records'];
             App::uses('Model', 'Model');
             $modelObject =& new Model(array('name' => $modelAlias, 'table' => $table, 'ds' => 'default'));
             if (is_array($records) && count($records) > 0) {
                 foreach ($records as $record) {
                     $modelObject->create($record);
                     $modelObject->save();
                 }
                 $modelObject->getDatasource()->resetSequence($modelObject->useTable, $modelObject->primaryKey);
             }
             ClassRegistry::removeObject($modelAlias);
         }
     }
     return $migrationsSucceed;
 }
 public function setUp()
 {
     parent::setUp();
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->_cssDir = $this->_pluginPath . 'Test' . DS . 'test_files' . DS . 'css' . DS;
     $this->filter = new SimpleCssMin();
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->PdfGenerator = ClassRegistry::init('PdfGenerator.PdfGenerator');
     $this->pluginPath = App::pluginPath('PdfGenerator');
     $this->setDefaultConfig();
 }
Ejemplo n.º 11
0
 public function setUp()
 {
     $this->Env = AssetEnvironment::getInstance(App::pluginPath('Asset') . DS . 'Test' . DS . 'test_app' . DS . 'webroot' . DS);
     $this->Asset = $this->getMock('CssAsset', array(), array('url', 'file'));
     $this->Context = $this->getMock('AssetContext');
     $this->Processor = new AssetProcessor($this->Asset, $this->Context);
 }
 /**
  * Suite define the tests for this suite
  *
  * @return void
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All NLP Data Source Tests');
     $path = App::pluginPath('ExcludeSimilarDocs') . 'Test' . DS . 'Case' . DS;
     $suite->addTestFile($path . 'Model' . DS . 'ExcludeSimilarDocsTest.php');
     return $suite;
 }
Ejemplo n.º 13
0
 public function render($action = null, $layout = null, $file = null)
 {
     if (!file_exists(VIEWS . 'utags' . DS . $action . '.ctp')) {
         $file = App::pluginPath('tags') . 'views' . DS . 'tags' . DS . $action . '.ctp';
     }
     return parent::render($action, $layout, $file);
 }
Ejemplo n.º 14
0
 function create($width = '120', $height = '40', $characters = '6')
 {
     if ($this->font == null) {
         $this->font = App::pluginPath($this->Controller->plugin) . DS . 'webroot' . DS . 'monofont.ttf';
     }
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.7;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 220, 220, 220);
     $text_color = imagecolorallocate($image, 10, 30, 80);
     $noise_color = imagecolorallocate($image, 150, 180, 220);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function');
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     $y -= 5;
     $slope = rand(3, 8);
     $slope = rand(0, 1) == 1 ? $slope : -$slope;
     imagettftext($image, $font_size, $slope, $x, $y, $text_color, $this->font, $code) or die('Error in imagettftext function');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     $this->Controller->Session->write('security_code', $code);
 }
Ejemplo n.º 15
0
 /**
  * setUp
  */
 public function setUp()
 {
     parent::setUp();
     $this->_setupPaths();
     $this->Init = new Init();
     $this->Init->appPath = App::pluginPath('Oven') . 'Test' . DS . 'test_app' . DS;
 }
Ejemplo n.º 16
0
 /**
  * __construct
  *
  * @param object $request
  * @param object $response
  */
 public function __construct($request = null, $response = null)
 {
     parent::__construct($request, $response);
     App::uses('OvenConfig', 'Oven.Lib');
     new OvenConfig();
     App::build(array('View' => array(App::pluginPath('Oven') . 'Lib' . DS . 'View' . DS)), App::PREPEND);
 }
Ejemplo n.º 17
0
 /**
  * setup
  */
 public function setUp()
 {
     parent::setUp();
     $controller = null;
     $this->View = new View($controller);
     $this->Image = new ImageHelper($this->View, array('imagePath' => App::pluginPath('Oven') . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS, 'cachePath' => App::pluginPath('Oven') . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'imagecache' . DS, 'urlBase' => ''));
 }
 /**
  * start a test
  *
  * @return void
  **/
 function startTest()
 {
     $this->JsFiles = new JsFilesControllerMock();
     $this->JsFiles->plugin = 'AssetCompress';
     $this->JsFiles->JsFile = new JsFileMock();
     $this->_pluginPath = App::pluginPath('AssetCompress');
 }
Ejemplo n.º 19
0
 /**
  * setUp
  */
 public function setUp()
 {
     parent::setUp();
     $this->_setupPaths();
     $this->Oven = ClassRegistry::init('Oven.Oven');
     $this->Oven->appPath = App::pluginPath('Oven') . 'Test' . DS . 'test_app' . DS;
 }
Ejemplo n.º 20
0
 public function setUp()
 {
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->filter = new ImportInline();
     $settings = array('paths' => array($this->_pluginPath . 'Test/test_files/css/'));
     $this->filter->settings($settings);
 }
/**
 * start a test
 *
 * @return void
 */
	public function setUp() {
		parent::setUp();
		$this->_pluginPath = App::pluginPath('AssetCompress');
		$this->_testFiles = $this->_pluginPath . 'Test' . DS . 'test_files' . DS;
		$testFile = $this->_testFiles . 'Config' . DS . 'config.ini';

		AssetConfig::clearAllCachedKeys();

		Cache::drop(AssetConfig::CACHE_CONFIG);
		Cache::config(AssetConfig::CACHE_CONFIG, array(
			'path' => TMP,
			'prefix' => 'asset_compress_test_',
			'engine' => 'File'
		));

		$controller = null;
		$request = new CakeRequest(null, false);
		$request->webroot = '';
		$view = new View($controller);
		$view->request = $request;
		$this->Helper = new AssetCompressHelper($view, array('noconfig' => true));
		$Config = AssetConfig::buildFromIniFile($testFile);
		$this->Helper->config($Config);
		$this->Helper->Html = new HtmlHelper($view);

		Router::reload();
		Configure::write('debug', 2);
	}
Ejemplo n.º 22
0
 public function resolveProvider()
 {
     $path = App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'webroot' . DS;
     $themePath = App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'View' . DS . 'Themed' . DS . 'Admin' . DS . 'webroot' . DS;
     $pluginPath = App::pluginPath('Asset') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS . 'Other' . DS . 'webroot' . DS;
     return array(array('css/bundle.css', $path . 'css' . DS . 'bundle.css'), array('css/default.css', $path . 'css' . DS . 'default.css'), array('css/app/bundle.css', $path . 'css' . DS . 'app' . DS . 'bundle.css'), array('theme/admin/css/bundle.css', $themePath . 'css' . DS . 'bundle.css'), array('other/css/bundle.css', $pluginPath . 'css' . DS . 'bundle.css'));
 }
Ejemplo n.º 23
0
 /**
  * Suite define the tests for this suite
  *
  * @return void
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All Task Tests');
     $path = App::pluginPath('Task') . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectoryRecursive($path);
     return $suite;
 }
Ejemplo n.º 24
0
 public function startTest($method)
 {
     parent::startTest($method);
     $this->path = App::pluginPath('upload') . 'tests' . DS . 'images' . DS;
     $source = $this->path . 'panda.jpg';
     $this->ImageGd = new ImageGd($source);
 }
Ejemplo n.º 25
0
	function __getClass($className) {
		$this->type = null;
		$classType = false;
		$className = $this->__fixClassName($className);

		if ($this->type) {
			$types = array($this->type);
		} else {
			$types = array('model', 'helper');
		}

		$class = $className;
		if (strpos($className, '.') !== false) {
			list($plugin, $className) = explode('.', $className);
			$this->objectPath = App::pluginPath($plugin);
		}

		foreach($types as $type) {
			$objects = Configure::listObjects(
				$type,
				$this->objectPath ? $this->objectPath . Inflector::pluralize($type) . DS : null,
				$this->objectCache
			);
			if (in_array($className, $objects)) {
				$classType = $type;
				break;
			}
		}

		switch ($classType) {
			case 'model':
				return ClassRegistry::init($class);
			case 'controller':
				App::import('Controller', $class);
				$className = $className . 'Controller';
				return new $className();
			case 'component':
				App::import('Controller', 'Controller');
				$Controller = new Controller();
				$Controller->params['action'] = '';
				App::import('Component', $class);
				$className = $className . 'Component';
				$Class = new $className();
				$Class->initialize($Controller);
				$Class->startup($Controller);
				return $Class;
			case 'helper':
				$this->raw = true;
				App::import('Controller', 'Controller');
				$Controller = new Controller();
				$Controller->helpers[] = $class;
				App::import('View', 'View');
				$View =& new View($Controller);
				$loaded = array();
				$helpers = $View->_loadHelpers($loaded, $Controller->helpers);
				return $helpers[$className];
		}

		return false;
	}
 /**
  * 	All AdvancedShell tests suite
  *
  * @return PHPUnit_Framework_TestSuite the instance of PHPUnit_Framework_TestSuite
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All AdvancedShell Tests');
     $basePath = App::pluginPath('AdvancedShell') . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectoryRecursive($basePath);
     return $suite;
 }
Ejemplo n.º 27
0
 function setUp()
 {
     $this->_pluginPath = App::pluginPath('AssetCompress');
     $this->_testFiles = $this->_pluginPath . 'tests' . DS . 'test_files' . DS;
     $paths = array($this->_testFiles . 'js' . DS, $this->_testFiles . 'js' . DS . 'classes' . DS);
     $this->Scanner = new AssetScanner($paths);
 }
Ejemplo n.º 28
0
 function getElementName()
 {
     if (!$this->element) {
         if ($this->name == 'FilterType') {
             $this->element = 'default_filter';
             $this->elemPlugin = 'CustomFilter';
         } else {
             $path = APP;
             if ($this->plugin) {
                 $path = App::pluginPath($this->plugin);
             }
             $path .= 'view' . DS . 'elements' . DS . Inflector::underscore($this->name) . '_filter';
             if (file_exists($path)) {
                 $this->element = Inflector::underscore($this->name) . '_filter';
                 $this->elemPlugin = $this->plugin ? $this->plugin : false;
             } else {
                 $this->element = 'default_filter';
                 $this->elemPlugin = 'CustomFilter';
             }
         }
     }
     if (is_null($this->elemPlugin)) {
         $this->elemPlugin = $this->plugin ? $this->plugin : false;
     }
     return array('elem' => $this->element, 'plugin' => $this->elemPlugin);
 }
 /**
  * Get Test Files
  *
  * @param null $directory
  * @param null $excludes
  * @return array
  */
 public static function getTestFiles($directory = null, $excludes = null)
 {
     if (is_array($directory)) {
         $files = array();
         foreach ($directory as $d) {
             $files = array_merge($files, self::getTestFiles($d, $excludes));
         }
         return array_unique($files);
     }
     if ($excludes !== null) {
         $excludes = self::getTestFiles((array) $excludes);
     }
     if ($directory === null || $directory !== realpath($directory)) {
         $basePath = App::pluginPath('DebugKit') . 'Test' . DS . 'Case' . DS;
         $directory = str_replace(DS . DS, DS, $basePath . $directory);
     }
     $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory));
     $files = array();
     while ($it->valid()) {
         if (!$it->isDot()) {
             $file = $it->key();
             if (preg_match('|Test\\.php$|', $file) && $file !== __FILE__ && !preg_match('|^All.+?\\.php$|', basename($file)) && ($excludes === null || !in_array($file, $excludes))) {
                 $files[] = $file;
             }
         }
         $it->next();
     }
     return $files;
 }
 /**
  * 	All GoogleChart tests suite
  *
  * @return PHPUnit_Framework_TestSuite the instance of PHPUnit_Framework_TestSuite
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All GoogleChart Tests');
     $basePath = App::pluginPath('GoogleChart') . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectoryRecursive($basePath);
     return $suite;
 }