public function testParse()
 {
     $path = CakePlugin::path('Translations') . 'Test/Files/simple.plist';
     $result = PlistParser::parse($path);
     $expected = array('count' => 1, 'translations' => array(array('locale' => 'en', 'domain' => 'default', 'category' => 'LC_MESSAGES', 'key' => 'foo', 'value' => 'foo value')));
     $this->assertSame($expected, $result);
 }
 /**
  * Suite define the tests for this suite
  *
  * @return void
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All Bs3Helpers tests');
     $path = CakePlugin::path('Bs3Helpers') . 'Test' . DS . 'Case' . DS . 'View' . DS . 'Helper' . DS;
     $suite->addTestDirectory($path);
     return $suite;
 }
 /**
  * HtmlExtHelperTest::testImageFromBlob()
  *
  * @return void
  */
 public function testImageFromBlob()
 {
     $folder = CakePlugin::path('Tools') . 'Test' . DS . 'test_files' . DS . 'img' . DS;
     $content = file_get_contents($folder . 'hotel.png');
     $is = $this->Html->imageFromBlob($content);
     $this->assertTrue(!empty($is));
 }
Esempio n. 4
0
 protected function _configTestFile($path = null, $baseKey = null)
 {
     if ($path === null) {
         $path = CakePlugin::path('YamlReader') . 'Test' . DS . 'files' . DS;
     }
     Configure::config('YamlTestConfig', new YamlReader($path, $baseKey));
 }
Esempio n. 5
0
 public function setUp()
 {
     $this->FileManager = new FileManager(false, null, null, null);
     $this->__testAppPath = CakePlugin::path('FileManager') . 'Test' . DS . 'test_app' . DS;
     $this->__setFilePathsForTests();
     parent::setUp();
 }
Esempio n. 6
0
 /**
  * Generates the base path to a set of tests based on the parameters.
  *
  * @param array $params
  * @return string The base path.
  */
 protected static function _basePath($params)
 {
     $result = null;
     if (!empty($params['core'])) {
         $result = CORE_TEST_CASES;
         // CUSTOMIZE ADD 2014/07/02 ryuring
         // >>>
     } elseif ($params['baser']) {
         $result = BASER_TEST_CASES;
         // <<<
     } elseif (!empty($params['plugin'])) {
         if (!CakePlugin::loaded($params['plugin'])) {
             try {
                 CakePlugin::load($params['plugin']);
                 $result = CakePlugin::path($params['plugin']) . 'Test' . DS . 'Case';
             } catch (MissingPluginException $e) {
             }
         } else {
             $result = CakePlugin::path($params['plugin']) . 'Test' . DS . 'Case';
         }
     } elseif (!empty($params['app'])) {
         $result = APP_TEST_CASES;
     }
     return $result;
 }
 public static function suite()
 {
     $suite = new CakeTestSuite('OAuth Tests');
     $path = CakePlugin::path('OAuth') . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectory($path . 'Model' . DS . 'Behavior');
     return $suite;
 }
 public function setUp()
 {
     parent::setUp();
     App::build(['Model' => [CakePlugin::path('Tools') . 'Test' . DS . 'test_app' . DS . 'Model' . DS]], App::RESET);
     $this->Comment = ClassRegistry::init('BitmaskedComment');
     $this->Comment->Behaviors->load('Tools.Bitmasked', ['mappedField' => 'statuses']);
 }
 /**
  * Suite define the tests for this suite
  *
  * @return void
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All Datasources test');
     $path = CakePlugin::path('InlineCss') . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectoryRecursive($path);
     return $suite;
 }
Esempio n. 10
0
 /**
  * Initialization.
  *
  * It loads the required classes for web and cli environments.
  *
  * @throws ConfigureException if needed configuration parameters are not found.
  * @param array $config Configuration options.
  * @return void
  */
 public static function init($config = null)
 {
     self::loadConfig($config);
     if (!($redis = Configure::read('CakeResque.Redis')) || !($resqueLib = Configure::read('CakeResque.Resque.lib')) || !($schedulerLib = Configure::read('CakeResque.Scheduler.lib')) || !($statusLib = Configure::read('CakeResque.Status.lib'))) {
         throw new ConfigureException(__d('cake_resque', 'There is an error in the configuration file.'));
     }
     if (empty($redis['host']) || empty($redis['port']) || empty($redis['database']) && !is_numeric($redis['database']) || empty($redis['namespace'])) {
         throw new ConfigureException(__d('cake_resque', 'There is an error in the Redis configuration key.'));
     }
     $pluginVendorPath = CakePlugin::path('CakeResque') . 'vendor' . DS;
     if (!Folder::isAbsolute($resqueLib)) {
         $resqueLib = $pluginVendorPath . $resqueLib;
     }
     $resqueLib .= DS . 'lib' . DS;
     if (!Folder::isAbsolute($schedulerLib)) {
         $schedulerLib = $pluginVendorPath . $schedulerLib;
     }
     $schedulerLib .= DS . 'lib' . DS . 'ResqueScheduler' . DS;
     if (!Folder::isAbsolute($statusLib)) {
         $statusLib = $pluginVendorPath . $statusLib;
     }
     require_once realpath($resqueLib . 'Resque.php');
     require_once realpath($resqueLib . 'Resque' . DS . 'Worker.php');
     require_once realpath($schedulerLib . 'ResqueScheduler.php');
     require_once realpath($schedulerLib . 'Stat.php');
     require_once realpath($schedulerLib . 'Job' . DS . 'Status.php');
     require_once realpath($statusLib . DS . 'src' . DS . 'ResqueStatus' . DS . 'ResqueStatus.php');
     Resque::setBackend($redis['host'] . ':' . $redis['port'], $redis['database'], $redis['namespace']);
 }
 /**
  * Suite define the tests for this plugin
  *
  * @return void
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All VatNumberCheck test');
     $path = CakePlugin::path('VatNumberCheck') . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectoryRecursive($path);
     return $suite;
 }
Esempio n. 12
0
 public static function suite()
 {
     $suite = new CakeTestSuite('All Extensions plugin tests');
     $path = CakePlugin::path('Extensions') . DS . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectory($path . 'Lib');
     return $suite;
 }
 /**
  * Suite define the tests for this suite
  *
  * @return void
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All AllAnnotationControlList test');
     $path = CakePlugin::path('AnnotationControlList') . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectoryRecursive($path);
     return $suite;
 }
 /**
  * setUp method
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('Plugin' => array(CakePlugin::path('Migrations') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), APP::RESET);
     $this->connection = 'test';
     $this->Migrations = new Migrations($this->connection);
 }
Esempio n. 15
0
 /**
  * Builds asset file path based off url
  *
  * @param string $url
  * @return string Absolute path for asset file
  */
 static function getAssetFile($url)
 {
     $parts = explode('/', $url);
     if ($parts[0] === 'theme') {
         $file = '';
         $fileFragments = explode(',', $url);
         $fileNumber = count($fileFragments);
         foreach ($fileFragments as $k => $fileFragment) {
             $fileParts = explode('/', $fileFragment);
             unset($fileParts[0], $fileParts[1]);
             if ($fileNumber == $k + 1) {
                 $file .= urldecode(implode(DS, $fileParts));
             } else {
                 $file .= urldecode(implode(DS, $fileParts)) . ',';
             }
         }
         $themeName = $parts[1];
         $path = Configure::read('App.www_root') . 'theme' . DS . $themeName;
         if (!file_exists($path)) {
             $path = App::themePath($themeName) . 'webroot';
         }
         return array($path, $file);
     }
     $plugin = Inflector::camelize($parts[0]);
     if (CakePlugin::loaded($plugin)) {
         unset($parts[0]);
         $fileFragment = urldecode(implode(DS, $parts));
         $pluginWebroot = CakePlugin::path($plugin) . 'webroot';
         return array($pluginWebroot, $fileFragment);
     } else {
         return array(WWW_ROOT, $_GET['f']);
     }
 }
Esempio n. 16
0
 public static function suite()
 {
     $suite = new CakeTestSuite('All Acl component class tests');
     $path = CakePlugin::path('Acl') . DS . 'Test' . DS . 'Case';
     $suite->addTestDirectory($path . DS . 'Controller' . DS . 'Component');
     return $suite;
 }
Esempio n. 17
0
 /**
  * Start test
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->Version = new MigrationVersion(array('connection' => 'test', 'autoinit' => false));
     App::build(array('plugins' => CakePlugin::path('Migrations') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS));
     Configure::write('Config.language', 'en');
 }
Esempio n. 18
0
 /**
  * アバター自動生成処理
  *
  * @param Model $model ビヘイビア呼び出し元モデル
  * @param array $user ユーザデータ配列
  * @return mixed On success Model::$data, false on failure
  * @throws InternalErrorException
  */
 public function createAvatarAutomatically(Model $model, $user)
 {
     //imagickdraw オブジェクトを作成します
     $draw = new ImagickDraw();
     //文字色のセット
     $draw->setfillcolor('white');
     //フォントサイズを 160 に設定します
     $draw->setFontSize(140);
     //テキストを追加します
     $draw->setFont(CakePlugin::path($model->plugin) . 'webroot' . DS . 'fonts' . DS . 'ipaexg.ttf');
     $draw->annotation(19, 143, mb_substr(mb_convert_kana($user['User']['handlename'], 'KVA'), 0, 1));
     //新しいキャンバスオブジェクトを作成する
     $canvas = new Imagick();
     //ランダムで背景色を指定する
     $red1 = strtolower(dechex(mt_rand(3, 12)));
     $red2 = strtolower(dechex(mt_rand(0, 15)));
     $green1 = strtolower(dechex(mt_rand(3, 12)));
     $green2 = strtolower(dechex(mt_rand(0, 15)));
     $blue1 = strtolower(dechex(mt_rand(3, 12)));
     $blue2 = strtolower(dechex(mt_rand(0, 15)));
     $canvas->newImage(179, 179, '#' . $red1 . $red2 . $green1 . $green2 . $blue1 . $blue2);
     //ImagickDraw をキャンバス上に描画します
     $canvas->drawImage($draw);
     //フォーマットを PNG に設定します
     $canvas->setImageFormat('png');
     App::uses('TemporaryFolder', 'Files.Utility');
     $folder = new TemporaryFolder();
     $filePath = $folder->path . DS . Security::hash($user['User']['handlename'], 'md5') . '.png';
     $canvas->writeImages($filePath, true);
     return $filePath;
 }
Esempio n. 19
0
 public function setUp()
 {
     $this->_paths = App::paths();
     $app = CakePlugin::path('Menus') . 'Test' . DS . 'test_app' . DS;
     App::build(array('Controller' => array($app . 'Controller' . DS), 'View' => array($app . 'View' . DS)));
     $this->generate('MenusTest');
 }
Esempio n. 20
0
 protected function _getFullAssetPath($path)
 {
     $filepath = preg_replace('/^' . preg_quote($this->Helper->request->webroot, '/') . '/', '', urldecode($path));
     $webrootPath = WWW_ROOT . str_replace('/', DS, $filepath);
     if (file_exists($webrootPath)) {
         //@codingStandardsIgnoreStart
         return $webrootPath;
         //@codingStandardsIgnoreEnd
     }
     $segments = explode('/', ltrim($filepath, '/'));
     if ($segments[0] === 'theme') {
         $theme = $segments[1];
         unset($segments[0], $segments[1]);
         $themePath = App::themePath($theme) . 'webroot' . DS . implode(DS, $segments);
         //@codingStandardsIgnoreStart
         return $themePath;
         //@codingStandardsIgnoreEnd
     } else {
         $plugin = Inflector::camelize($segments[0]);
         if (CakePlugin::loaded($plugin)) {
             unset($segments[0]);
             $pluginPath = CakePlugin::path($plugin) . 'webroot' . DS . implode(DS, $segments);
             //@codingStandardsIgnoreStart
             return $pluginPath;
             //@codingStandardsIgnoreEnd
         }
     }
     return false;
 }
Esempio n. 21
0
 /**
  * Suite define the tests for this suite
  *
  * @return void
  */
 public static function suite()
 {
     $Suite = new CakeTestSuite('All Comments Plugin tests');
     $basePath = CakePlugin::path('TinyMCE') . DS . 'Test' . DS . 'Case' . DS;
     $Suite->addTestDirectory($basePath . DS . 'View' . DS . 'Helper');
     return $Suite;
 }
Esempio n. 22
0
 public function setUp()
 {
     parent::setUp();
     App::build(array('Plugin' => array(CakePlugin::path('Extensions') . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS)), App::PREPEND);
     $this->CroogoPlugin = new CroogoPlugin();
     $this->_mapping = array(1346748762 => array('version' => 1346748762, 'name' => '1346748762_first', 'class' => 'First', 'type' => 'app', 'migrated' => '2012-09-04 10:52:42'), 1346748933 => array('version' => 1346748933, 'name' => '1346748933_addstatus', 'class' => 'AddStatus', 'type' => 'app', 'migrated' => '2012-09-04 10:55:33'));
 }
 /**
  * Get a list of plugins on construct for later use
  */
 public function __construct()
 {
     foreach (CakePlugin::loaded() as $plugin) {
         $this->_pluginPaths[$plugin] = CakePlugin::path($plugin);
     }
     parent::__construct();
 }
Esempio n. 24
0
 public function main()
 {
     $wsdl = $path = $plugin = null;
     while (!$wsdl) {
         $wsdl = $this->in('Enter the url of the wsdl');
     }
     while (!$path) {
         $path = $this->in('Save to App or a plugin?', array('app', 'plugin'));
     }
     if ($path == 'plugin') {
         $loaded = CakePlugin::loaded();
         while (!$plugin) {
             $plugin = $this->in('Select plugin', $loaded);
             if (!in_array($plugin, $loaded)) {
                 $plugin = null;
             }
         }
         $path = CakePlugin::path($plugin) . 'Lib';
         $plugin .= '.';
     } else {
         $path = APP . 'Lib';
     }
     $wsdlInterpreter = new WSDLInterpreter($wsdl);
     $return = $wsdlInterpreter->savePHP($path);
     $path .= DS;
     $file = str_replace($path, '', $return[0]);
     $class = substr($file, 0, -4);
     $this->hr();
     $this->out('Lib saved to:' . $path . $file);
     $text = "'lib' => '" . $plugin . $class . "'";
     $this->out("Add 'lib' key to the config in database.php: " . $text);
     $this->hr();
 }
Esempio n. 25
0
 /**
  * All test suite
  *
  * @return CakeTestSuite
  */
 public static function suite()
 {
     $plugin = preg_replace('/^All([\\w]+)Test$/', '$1', __CLASS__);
     $suite = new CakeTestSuite(sprintf('All %s Plugin tests', $plugin));
     $suite->addTestDirectoryRecursive(CakePlugin::path($plugin) . 'Test' . DS . 'Case');
     return $suite;
 }
Esempio n. 26
0
 public function testParsePlural()
 {
     $path = CakePlugin::path('Translations') . 'Test/Files/plural.po';
     $result = PoParser::parse($path);
     $expected = array('count' => 3, 'translations' => array(array('locale' => 'en', 'domain' => 'plural', 'category' => 'LC_MESSAGES', 'key' => '%d post', 'value' => '1 post'), array('locale' => 'en', 'domain' => 'plural', 'category' => 'LC_MESSAGES', 'key' => '%d posts', 'value' => '1 post', 'single_key' => '%d post', 'plural_case' => 0), array('locale' => 'en', 'domain' => 'plural', 'category' => 'LC_MESSAGES', 'key' => '%d posts', 'value' => '%d many posts', 'single_key' => '%d post', 'plural_case' => 1)), 'settings' => array('domain' => 'plural'));
     $this->assertSame($expected, $result);
 }
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     App::build(array('View' => array(CakePlugin::path('Taxonomy') . 'View' . DS)), App::APPEND);
     $this->VocabulariesController = $this->generate('Taxonomy.Vocabularies', array('methods' => array('redirect'), 'components' => array('Auth' => array('user'), 'Session')));
     $this->VocabulariesController->Auth->staticExpects($this->any())->method('user')->will($this->returnCallback(array($this, 'authUserCallback')));
 }
Esempio n. 28
0
 /**
  * Suite define the tests for this suite
  *
  * @return void
  */
 public static function suite()
 {
     $suite = new PHPUnit_Framework_TestSuite('All Oauth Plugin Tests');
     $basePath = CakePlugin::path('OauthLib') . 'Test' . DS . 'Case' . DS;
     $libs = $basePath . 'Lib' . DS;
     $tokens = $libs . 'Token' . DS;
     $spec = $basePath . 'Spec' . DS;
     // Libs
     $suite->addTestFile($libs . 'ClientHttpGoogleTest.php');
     $suite->addTestFile($libs . 'ClientHttpTermieTest.php');
     $suite->addTestFile($libs . 'ClientHttpTest.php');
     $suite->addTestFile($libs . 'ConsumerGoogleTest.php');
     $suite->addTestFile($libs . 'ConsumerTest.php');
     $suite->addTestFile($libs . 'HmacTest.php');
     $suite->addTestFile($libs . 'RequestFactoryTest.php');
     $suite->addTestFile($libs . 'SignatureTest.php');
     // Libs/Token
     $suite->addTestFile($tokens . 'AccessTokenTest.php');
     $suite->addTestFile($tokens . 'RequestTokenTest.php');
     $suite->addTestFile($tokens . 'TokenTest.php');
     // Libs/RequestProxy
     $suite->addTestFile($libs . 'RequestProxy' . DS . 'RequestProxyControllerTest.php');
     $suite->addTestFile($libs . 'RequestProxy' . DS . 'RequestProxyHttpTest.php');
     // Spec
     $suite->addTestFile($spec . 'ConstructRequestUrlTest.php');
     $suite->addTestFile($spec . 'NormalizeRequestParametersTest.php');
     $suite->addTestFile($spec . 'SignatureBaseStringsTest.php');
     return $suite;
 }
Esempio n. 29
0
 /**
  * Suite define the tests for this suite
  *
  * @return void
  */
 public static function suite()
 {
     $suite = new CakeTestSuite('All Users tests');
     $path = CakePlugin::path('Users') . 'Test' . DS . 'Case' . DS;
     $suite->addTestDirectoryRecursive($path);
     return $suite;
 }
 /**
  * startTest
  *
  * @return void
  */
 public function setUp()
 {
     $this->Model = new VoidUploadModel();
     $this->Model->Behaviors->load('FileStorage.UploadValidator', array('localFile' => true));
     $this->FileUpload = $this->Model->Behaviors->UploadValidator;
     $this->testFilePath = CakePlugin::path('FileStorage') . 'Test' . DS . 'Fixture' . DS . 'File' . DS;
 }