function setCommonConfig(Config &$config, $serverName = null) { // Config that can be carried over to any server if (empty($serverName) && isset($_SERVER["SERVER_NAME"])) { $serverName = $_SERVER["SERVER_NAME"]; } // clientAndServer configs are readable via javascript. if ($serverName == 'localhost' || $serverName == 'test') { $serverConfigAdd = array('imagecachesPath' => BASE_PATH . 'images/cache/', 'isDevMode' => false, 'logSql' => false); $clientAndServerConfigAdd = array('baseUrl' => 'http://localhost/skully-amazon-s3/Tests/app/', 'publicDir' => 'public/'); } else { $serverConfigAdd = array('imagecachesPath' => BASE_PATH . 'images/cache/', 'isDevMode' => false, 'logSql' => false); $clientAndServerConfigAdd = array('baseUrl' => 'http://onlinesite.com/', 'publicDir' => 'public/'); } $config_r = array_merge(array('namespace' => 'TestApp', 'caching' => 0, 'maintenance' => false, 'maintenanceIp' => '139.195.146.93', "dateFormatDb" => "Y-m-d H:i:s", 'dateFormat' => 'd M Y', 'longDateTimeFormat' => 'M j, Y h:i A', 'shortDateTimeFormat' => 'd/m H:i', 'longDateFormat' => 'M j, Y', 'shortDateFormat' => 'd/m', 'adminLongDateTimeFormat' => 'd/m/Y H:i', 'adminLongDateFormat' => 'd/m/Y', 'urlRules' => array('' => 'admin/home/index', 'admin' => 'admin/home/index', 'admin/index' => 'admin/home/index', 'admin/loginProcess' => 'admin/admins/loginProcess', 'admin/login' => 'admin/admins/login'), 'language' => 'en', 'languages' => array('en' => array('value' => 'english', 'code' => 'en')), 'smtpPort' => '465', 'smtpHost' => 'smtp.google.com', 'smtpPassword' => 'password', 'smtpUsername' => '*****@*****.**', 'senderEmail' => '*****@*****.**', 'senderName' => 'SenderName', 'replyToEmail' => '*****@*****.**', 'replyToName' => 'yoursite.com Contact', 'smtpSecurity' => 'ssl', 'basePath' => BASE_PATH, 'globalSalt' => 'hakunamatata', 'ruckusingConfig' => array('migrations_dir' => array('default' => BASE_PATH . 'migrations'), 'db_dir' => BASE_PATH . 'db', 'log_dir' => BASE_PATH . 'logs' . DIRECTORY_SEPARATOR . 'migrations', 'ruckusing_base' => RUCKUSING_BASE), 'additionalCommands' => array('\\SkullyAwsS3\\Skully\\Commands\\S3Command')), $serverConfigAdd); $clientAndServerConfig = array_merge(array('theme' => 'default', 'formDateFormat' => 'M d, yy', 'serverFormDateFormat' => "%b %e, %Y", 'formTimeFormat' => 'hh:mm TT', 'serverFormDateTimeFormat' => "%b %e, %Y %I:%M %p"), $clientAndServerConfigAdd); $config_r = array_merge($config_r, $clientAndServerConfig); $config->setProtectedFromArray($config_r); $clientConfig = array(); $clientConfig = array_merge($clientConfig, $clientAndServerConfig); $config->setPublicFromArray($clientConfig); // Copy credentials.csv from AmazonS3 website into directory "config/AmazonS3/" $csv = file_get_contents(realpath(__DIR__ . '/AmazonS3/credentials.csv')); $csv_r = explode("\n", $csv); $s3Config = explode(',', trim($csv_r[1])); $s3Config[0] = str_replace('"', '', $s3Config[0]); $config->setProtectedFromArray(array('amazonS3' => array('enabled' => true, 'bucket' => 'skully-admin', 'region' => 's3-ap-southeast-1', 'settings' => array('profile' => $s3Config[0], 'key' => $s3Config[1], 'secret' => $s3Config[2])))); }
function setUniqueConfig(Config &$config, $serverName = null) { if (empty($serverName)) { $serverName = $_SERVER["SERVER_NAME"]; } if ($serverName == 'localhost') { /** * LOCALHOST */ $config_r = array('serverName' => $serverName, "dbConfig" => array('type' => 'mysql', "host" => "127.0.0.1", "user" => "root", "password" => "oisadj", "port" => "3306", "dbname" => "skully", 'charset' => 'utf8')); } elseif ($serverName == 'test') { /** * TEST */ $config_r = array('serverName' => $serverName, "dbConfig" => array('type' => 'sqlite', "host" => "localhost", "user" => "", "password" => "", "port" => "", "dbname" => 'test.db', 'charset' => 'utf8')); } else { /** * ONLINE */ $config_r = array('serverName' => $serverName, "dbConfig" => array('type' => 'mysql', "host" => "", "user" => "", "password" => "", "port" => "3306", "dbname" => "online_database", 'charset' => 'utf8', 'directory' => 'skully')); } $config->setProtectedFromArray($config_r); if ($serverName == 'localhost') { $clientAndServerConfig = array(); } elseif ($serverName == 'test') { $clientAndServerConfig = array(); } else { $clientAndServerConfig = array(); } $config->setProtectedFromArray($clientAndServerConfig); $config->setPublicFromArray($clientAndServerConfig); }
function __setupApp() { $config = new Config(); $config->setProtected('basePath', BASE_PATH); setCommonConfig($config); setUniqueConfig($config); return new \App\Application($config); }
protected function getApp() { $structure = $this->appStructure(); $this->root = vfsStream::setup('root', 777, $structure); $config = new Config(); $config->setProtectedFromArray(array('theme' => 'test', 'basePath' => vfsStream::url('root'), 'baseUrl' => 'http://localhost/skully/', 'languages' => array('en' => array('value' => 'english', 'code' => 'en')), 'urlRules' => array('' => 'home/index', 'admin' => 'admin/home/index'), 'namespace' => 'App', 'caching' => 0)); setRealpath(); return new \App\Application($config); }
public function testNewsRoute() { $config = new Config(); $config->setProtectedFromArray(array('basePath' => realpath(dirname(__FILE__) . '/../../../../../../') . '/', 'baseUrl' => 'http://localhost/skully/', 'urlRules' => array('' => 'home/index', 'products/c/%cid' => 'products/viewCategory', 'products/index' => 'products/index', 'products/%id' => 'products/view', 'cart/add' => 'checkout/cartAdd', 'cart/index' => 'checkout/cart', 'cart/update' => 'checkout/updateCart', 'cart/remove' => 'checkout/removeItem', 'cart/apply-coupon' => 'checkout/applyCoupon', 'checkout/index' => 'checkout/checkout', 'klikpay' => 'payment/klikpay', 'admin' => 'admin/home/index', 'admin/index' => 'admin/home/index'), 'theme' => 'default', 'timezone' => 'Asia/Jakarta')); $app = new Application($config); $url = 'news/index?cid=1'; $controller = $app->getControllerFromRawUrl($url); $this->assertEquals('index', $controller->getCurrentAction()); $this->assertEquals('1', $controller->getParam('cid')); }
protected function getApp() { $structure = $this->getStructure(); $this->root = vfsStream::setup('root', 777, $structure); // print_r(vfsStream::inspect(new vfsStreamStructureVisitor())->getStructure()); $config = new Config(); $config->setProtectedFromArray(array('theme' => 'test', 'language' => 'en', 'languages' => array('en' => array('value' => 'english', 'code' => 'en')), 'basePath' => vfsStream::url('root'), 'skullyBasePath' => vfsStream::url('root/vendor/triodigital/skully/'), 'baseUrl' => 'http://localhost/skully/', 'urlRules' => array('' => 'home/index', 'admin' => 'admin/home/index'))); $_SESSION['__language'] = 'id'; $app = new \App\Application($config); unsetRealpath(); $pluginsPath = realpath(__DIR__ . '/../../App/smarty/plugins'); setRealpath(); $app->getTemplateEngine()->addPluginsDir($pluginsPath); return $app; }
protected function setUp() { $config = new Config(); $config->setProtected('basePath', BASE_PATH); setCommonConfig($config); setUniqueConfig($config); Application::setupRedBean('sqlite:test.db', 'user', 'password', $this->frozen, 'sqlite'); R::freeze(false); R::nuke(); R::freeze($this->frozen); $this->app = __setupApp(); /** $http Mock Http object. */ $http = $this->getMock('Skully\\Core\\Http'); $http->expects($this->any())->method('redirect')->will($this->returnCallback('stubRedirect')); $this->app->setHttp($http); }
public function testSmartyInstall() { $config = new Config(); $config->setProtectedFromArray(array('publicDir' => 'public/', 'caching' => 1, 'theme' => 'default', 'basePath' => realpath(__DIR__ . DIRECTORY_SEPARATOR . 'App') . DIRECTORY_SEPARATOR, 'baseUrl' => 'http://localhost/skully/', 'languages' => array('en' => array('value' => 'english', 'code' => 'en')), 'urlRules' => array('' => 'home/index', 'admin' => 'admin/home/index'), 'namespace' => 'App')); if (!file_exists(realpath(__DIR__ . '/App/App/smarty/plugins'))) { mkdir('./App/App/smarty/plugins'); } if (!file_exists(realpath(__DIR__ . '/App/App/smarty/cache'))) { mkdir('./App/App/smarty/cache'); } if (!file_exists(realpath(__DIR__ . '/App/App/smarty/configs'))) { mkdir('./App/App/smarty/configs'); } $app = new Application($config); $smarty = $app->getTemplateEngine()->getEngine(); $errors = array(); $smarty->testInstall($errors); echo "smarty errors: "; print_r($errors); $this->assertTrue(count($errors) <= 2); }
function setCommonConfig(Config &$config, $serverName = null) { // Config that can be carried over to any server if (empty($serverName)) { $serverName = $_SERVER["SERVER_NAME"]; } // clientAndServer configs are readable via javascript. if ($serverName == 'localhost' || $serverName == 'test') { $serverConfigAdd = array('imagecachesPath' => BASE_PATH . 'images/cache/', 'isDevMode' => false, 'logSql' => false); $clientAndServerConfigAdd = array('baseUrl' => 'http://localhost/localsite/', 'publicDir' => 'public/'); } else { $serverConfigAdd = array('imagecachesPath' => BASE_PATH . 'images/cache/', 'isDevMode' => false, 'logSql' => false); $clientAndServerConfigAdd = array('baseUrl' => 'http://onlinesite.com/', 'publicDir' => 'public/'); } $config_r = array_merge(array('freeze' => true, 'namespace' => 'App', 'caching' => 0, 'maintenance' => false, 'maintenanceIp' => '139.195.146.93', 'maintenancePath' => 'home/maintenance', 'notFoundPath' => 'home/notFound', "dateFormatDb" => "Y-m-d H:i:s", 'dateFormat' => 'd M Y', 'longDateTimeFormat' => 'M j, Y h:i A', 'shortDateTimeFormat' => 'd/m H:i', 'longDateFormat' => 'M j, Y', 'shortDateFormat' => 'd/m', 'adminLongDateTimeFormat' => 'd/m/Y H:i', 'adminLongDateFormat' => 'd/m/Y', 'urlRules' => array('' => 'home/index', 'admin' => 'admin/home/index', 'admin/index' => 'admin/home/index', 'admin/loginProcess' => 'admin/admins/loginProcess', 'admin/login' => 'admin/admins/login'), 'language' => 'en', 'languages' => array('en' => array('value' => 'english', 'code' => 'en')), 'smtpPort' => '465', 'smtpHost' => 'smtp.google.com', 'smtpPassword' => 'password', 'smtpUsername' => '*****@*****.**', 'senderEmail' => '*****@*****.**', 'senderName' => 'SenderName', 'replyToEmail' => '*****@*****.**', 'replyToName' => 'yoursite.com Contact', 'smtpSecurity' => 'ssl', 'basePath' => BASE_PATH, 'skullyBasePath' => null, 'globalSalt' => 'hakunamatata', 'ruckusingConfig' => array('migrations_dir' => array('default' => BASE_PATH . 'migrations'), 'db_dir' => BASE_PATH . 'db', 'log_dir' => BASE_PATH . 'logs' . DIRECTORY_SEPARATOR . 'migrations', 'ruckusing_base' => RUCKUSING_BASE)), $serverConfigAdd); $clientAndServerConfig = array_merge(array('theme' => 'default', 'formDateFormat' => 'M d, yy', 'serverFormDateFormat' => "%b %e, %Y", 'formTimeFormat' => 'hh:mm TT', 'serverFormDateTimeFormat' => "%b %e, %Y %I:%M %p"), $clientAndServerConfigAdd); $config_r = array_merge($config_r, $clientAndServerConfig); $config->setProtectedFromArray($config_r); $clientConfig = array(); $clientConfig = array_merge($clientConfig, $clientAndServerConfig); $config->setPublicFromArray($clientConfig); }
protected function getApp() { $config = new Config(); $config->setProtectedFromArray(array('publicDir' => 'public/', 'caching' => 1, 'theme' => 'test', 'basePath' => realpath(__DIR__ . DIRECTORY_SEPARATOR . 'App') . DIRECTORY_SEPARATOR, 'baseUrl' => 'http://localhost/skully/', 'languages' => array('en' => array('value' => 'english', 'code' => 'en')), 'urlRules' => array('' => 'home/index', 'admin' => 'admin/home/index'), 'namespace' => 'App')); return new \App\Application($config); }
public function testSetPublicFromArray() { $config = new Config(); $config->setPublicFromArray(array('test' => 'value')); $this->assertEquals('value', $config->getPublic('test')); }
public function setUp() { $config = new Config(); $config->setProtectedFromArray(array('basePath' => '/', 'urlRules' => array('' => 'home/index'), 'timezone' => 'Asia/Jakarta')); $this->app = new Application($config); }