public function testGet() { $c = new Config($this->container); $this->assertEquals('', $c->get('board_columns')); $this->assertEquals('test', $c->get('board_columns', 'test')); $this->assertEquals(0, $c->get('board_columns', 0)); }
public function testGet() { $c = new Config($this->registry); $this->assertEquals('', $c->get('default_columns')); $this->assertEquals('test', $c->get('default_columns', 'test')); $this->assertEquals(0, $c->get('default_columns', 0)); }
public function testCreation() { $p = new Project($this->container); $b = new Board($this->container); $c = new Config($this->container); // Default columns $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); $columns = $b->getColumnsList(1); $this->assertTrue(is_array($columns)); $this->assertEquals(4, count($columns)); $this->assertEquals('Backlog', $columns[1]); $this->assertEquals('Ready', $columns[2]); $this->assertEquals('Work in progress', $columns[3]); $this->assertEquals('Done', $columns[4]); // Custom columns: spaces should be trimed and no empty columns $input = ' column #1 , column #2, '; $this->assertTrue($c->save(array('board_columns' => $input))); $this->assertEquals($input, $c->get('board_columns')); $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'))); $columns = $b->getColumnsList(2); $this->assertTrue(is_array($columns)); $this->assertEquals(2, count($columns)); $this->assertEquals('column #1', $columns[5]); $this->assertEquals('column #2', $columns[6]); }
public function testCustomCss() { $h = new Asset($this->container); $c = new Config($this->container); $this->assertEmpty($h->customCss()); $this->assertTrue($c->save(array('application_stylesheet' => 'p { color: red }'))); $this->assertEquals('<style>p { color: red }</style>', $h->customCss()); }
public function testBase() { $h = new Url($this->container); $_SERVER['PHP_SELF'] = '/'; $_SERVER['SERVER_NAME'] = 'localhost'; $_SERVER['SERVER_PORT'] = 1234; $this->assertEquals('http://localhost:1234/', $h->base()); $c = new Config($this->container); $c->save(array('application_url' => 'https://mykanboard/')); $this->assertEquals('https://mykanboard/', $c->get('application_url')); $this->assertEquals('https://mykanboard/', $h->base()); }
/** * Standard preferences handling via preferences form subclass * * @param string $name Name of the form service * @return \Zend\View\Model\ViewModel|\Zend\Http\Response View model for "form.php" template or redirect response */ protected function _useForm($name) { $form = $this->_formManager->get($name); if ($this->getRequest()->isPost()) { $form->setData($this->params()->fromPost()); if ($form->isValid()) { // Flatten Preferences array, i.e. incorporate fields from a // fieldset into a single array. $this->_config->setOptions(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($form->getData()['Preferences']))); return $this->redirectToRoute('preferences', $this->getEvent()->getRouteMatch()->getParams()['action']); } } else { $preferences = array(); foreach ($form->get('Preferences') as $element) { $name = $element->getName(); if ($element instanceof \Zend\Form\Fieldset) { foreach ($element as $subElement) { $subElementName = $subElement->getName(); $preferences[$name][$subElementName] = $this->_config->{$subElementName}; } } else { $preferences[$name] = $this->_config->{$name}; } } $form->setData(array('Preferences' => $preferences)); } return $this->printForm($form); }
/** * 获取登录页URL * * @return string */ public static function showLoginUrl() { $url = 'https://github.com/login/oauth/authorize?client_id=%s&scope=public_repo'; $client_id = \Model\Config::show('github_client_id'); $result = sprintf($url, $client_id); return $result; }
public function index() { $twig = Config::getTwig(); $productId = Request::_request('productId'); $productDetail = \model\ProductList::getProduct($productId); //die( $productDetail) ; /*if (isset($_GET['marketId'])){ $marketId = $_GET['marketId']; // ########################################## // ########################################## // -- ** -- // Burada market sayfası için gerekli diğer sorgular yapılacaktır // - section Listesi // - genel ürün listesi (çok satılan vs) // - (+) diğer istekler // ########################################## // ########################################## $sectionList = \model\GuppyFunctions::prepareCategoryMenu(); }*/ $result = array('productDetail' => json_decode($productDetail)->content); //$result = array('products' => $productList); return $twig->render('client/product_detail2.html', $result); }
protected function process() { $model = new IndexModel(); $this->appendData($model->getData()); $lang = $this->getLanguage(); $this->appendData(['lang' => $lang, 'locale' => Config::getParam(Config::LN)[$lang]['locale'], 'apiRoot' => '/' . $lang . '/api/', 'headJs' => Config::getParam(Config::HEAD_JS), 'headCss' => Config::getParam(Config::HEAD_CSS), 'footJs' => Config::getParam(Config::FOOT_JS)]); }
/** * @return array */ public function getData() { $ret = []; $this->loadTranslations(); $this->addTranslationOfInToOut($this->directTransKeys, $ret); $lnUrl = DIRECTORY_SEPARATOR . Config::getLn(); $ret[self::MENU_ITEMS] = []; foreach ($this->menuItems as $name => $logo) { $translation = $this->trans($name); $ret[self::MENU_ITEMS][] = ['text' => $translation, 'link' => $lnUrl . '/' . $translation, 'logo' => $logo]; } $ret[self::INFO] = []; foreach ($this->settings as $info) { $out = []; $this->addTranslationOfInToOut($info, $out, $this->infoTransKeys); $out[self::ICONS] = []; foreach ($info[self::ICONS] as $icon) { $iconInfo = []; $this->addTranslationOfInToOut($icon, $iconInfo, ['title']); $iconInfo = $icon['class']; $out[self::ICONS][] = $iconInfo; } $ret[self::INFO][] = $out; } return $ret; }
public function setUp() { Config::addConfigFromPath(__DIR__ . '/testConfig.php'); $this->model = new Lang($this->settings); $this->testClassName = get_class($this->model); $this->reflection = new ReflectionClass($this->testClassName); }
public function getTemplateName() { $templatesPath = Config::getDir(CONFIG::VIEW); $fullPath = $templatesPath . DIRECTORY_SEPARATOR . self::PAGES_DIR . DIRECTORY_SEPARATOR . $this->pageName; if (!file_exists($fullPath)) { $this->app->notFound(); } return self::PAGES_DIR . DIRECTORY_SEPARATOR . $this->pageName; }
public function testCreationWithDefaultCategories() { $p = new Project($this->container); $c = new Config($this->container); $cat = new Category($this->container); // Multiple categories correctly formatted $this->assertTrue($c->save(array('project_categories' => 'Test1, Test2'))); $this->assertEquals(1, $p->create(array('name' => 'UnitTest1'))); $project = $p->getById(1); $this->assertNotEmpty($project); $categories = $cat->getAll(1); $this->assertNotEmpty($categories); $this->assertEquals(2, count($categories)); $this->assertEquals('Test1', $categories[0]['name']); $this->assertEquals('Test2', $categories[1]['name']); // Single category $this->assertTrue($c->save(array('project_categories' => 'Test1'))); $this->assertEquals(2, $p->create(array('name' => 'UnitTest2'))); $project = $p->getById(2); $this->assertNotEmpty($project); $categories = $cat->getAll(2); $this->assertNotEmpty($categories); $this->assertEquals(1, count($categories)); $this->assertEquals('Test1', $categories[0]['name']); // Multiple categories badly formatted $this->assertTrue($c->save(array('project_categories' => 'ABC, , DEF 3, '))); $this->assertEquals(3, $p->create(array('name' => 'UnitTest3'))); $project = $p->getById(3); $this->assertNotEmpty($project); $categories = $cat->getAll(3); $this->assertNotEmpty($categories); $this->assertEquals(2, count($categories)); $this->assertEquals('ABC', $categories[0]['name']); $this->assertEquals('DEF 3', $categories[1]['name']); // No default categories $this->assertTrue($c->save(array('project_categories' => ' '))); $this->assertEquals(4, $p->create(array('name' => 'UnitTest4'))); $project = $p->getById(4); $this->assertNotEmpty($project); $categories = $cat->getAll(4); $this->assertEmpty($categories); }
public static function index() { // -- ** -- GET Twig & city list $twig = Config::getTwig(); $cityList = Address::getCityList(); //die($_SERVER['REQUEST_URI']); // -- ** -- Check $cityList content is exist with isset method $result = array('cityList' => json_decode($cityList)->content); // -- ** -- Render result with twig return $twig->render('index.html', $result); }
public function testExportActionValidate() { $this->_config->expects($this->once())->method('__get')->with('validateXml')->willReturn('1'); $document = $this->createMock('\\Protocol\\Message\\InventoryRequest'); $document->expects($this->once())->method('forceValid'); $client = $this->createMock('Model\\Client\\Client'); $client->expects($this->once())->method('toDomDocument')->willReturn($document); $this->_clientManager->method('getClient')->willReturn($client); $this->dispatch('/console/client/export/?id=1'); $this->assertResponseStatusCode(200); }
public function testIcalEventsWithAssigneeAndDueDate() { $dp = new DateParser($this->container); $p = new Project($this->container); $tc = new TaskCreation($this->container); $tf = new TaskFilterICalendarFormatter($this->container); $u = new User($this->container); $c = new Config($this->container); $this->assertNotFalse($c->save(array('application_url' => 'http://kb/'))); $this->assertEquals('http://kb/', $c->get('application_url')); $this->assertNotFalse($u->update(array('id' => 1, 'email' => 'bob@localhost'))); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertNotFalse($tc->create(array('project_id' => 1, 'title' => 'task1', 'owner_id' => 1, 'date_due' => $dp->getTimestampFromIsoFormat('+5 days')))); $ics = $tf->create()->filterByDueDateRange(strtotime('-1 month'), strtotime('+1 month'))->setFullDay()->setCalendar(new Calendar('Kanboard'))->setColumns('date_due')->addFullDayEvents()->format(); $this->assertContains('UID:task-#1-date_due', $ics); $this->assertContains('DTSTART;TZID=UTC;VALUE=DATE:' . date('Ymd', strtotime('+5 days')), $ics); $this->assertContains('DTEND;TZID=UTC;VALUE=DATE:' . date('Ymd', strtotime('+5 days')), $ics); $this->assertContains('URL:http://kb/?controller=task&action=show&task_id=1&project_id=1', $ics); $this->assertContains('SUMMARY:#1 task1', $ics); $this->assertContains('ORGANIZER;CN=admin:MAILTO:bob@localhost', $ics); $this->assertContains('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE', $ics); }
/** * Logger constructor. * @param $logName */ public function __construct($logName) { try { $logDir = Config::getDir(Config::LOG); if (!file_exists($logDir)) { mkdir($logDir); } $this->logger = new Logger($logName); $this->logger->pushHandler(new StreamHandler($logDir, Logger::ERROR)); } catch (\Exception $e) { exit($e); } }
public function index() { $twig = Config::getTwig(); //-- Get Distrubuter -- // $distrName = Request::_get('id'); $categoryList = Category::getCategoryTree()->content; //-- Get Main Categories -- // $maincategoryList = $categoryList->childList; //-- Define Rendered Result -- // $result = array('categoryList' => $maincategoryList, 'distrName' => $distrName); //-- Render Result -- // return $twig->render('home.html', $result); }
public function index() { // -- ** -- GET Twig & city list $twig = Config::getTwig(); $loginResult = ProductList::getAllProducts(); //die($_SERVER['REQUEST_URI']); // -- ** -- Check $cityList content is exist with isset method $result = array('products' => $loginResult->content); // -- ** -- Render result with twig if ($loginResult->isSuccess()) { return $twig->render('admin/pages/tables/products.html', $result); } else { return $twig->render('admin/pages/tables/products.html', $result); } }
public function testProcessSetInspect() { $data = array('inspect' => array('inspect' => '1'), 'existing' => array(), 'new_value' => array('name' => '', 'root_key' => 'root_key', 'subkeys' => 'subkeys', 'value' => 'value')); $resultSet = new \Zend\Db\ResultSet\ResultSet(); $resultSet->initialize(array()); $registryManager = $this->createMock('Model\\Registry\\RegistryManager'); $registryManager->expects($this->once())->method('getValueDefinitions')->willReturn($resultSet); $registryManager->expects($this->never())->method('addValueDefinition'); $registryManager->expects($this->never())->method('renameValueDefinition'); $this->_config->expects($this->once())->method('__set')->with('inspectRegistry', '1'); $form = $this->getMockBuilder('Console\\Form\\ManageRegistryValues')->setMethods(array('getData'))->setConstructorArgs(array(null, array('config' => $this->_config, 'registryManager' => $registryManager)))->getMock(); $form->expects($this->once())->method('getData')->willReturn($data); $form->init(); $form->process(); }
public function asama_1() { //die(substr(dirname(__FILE__),0, strlen(dirname(__FILE__))-11)); //die(mbstr(dirname(__FILE__))); // -- ** -- GET Twig & city list $twig = Config::getTwig(); $cityList = Address::getCityList(); //die($cityList); //die($_SERVER['REQUEST_URI']); // -- ** -- Check $cityList content is exist with isset method $result = array('cityList' => json_decode($cityList)->content); print_r($cityList); // -- ** -- Render result with twig return $twig->render('index.html', $result); }
public function index() { // -- ** -- GET Twig & city list $twig = Config::getTwig(); $loginResult = Order::getOrder(Request::_get("id")); //die($_SERVER['REQUEST_URI']); // -- ** -- Check $cityList content is exist with isset method $result = array('order' => $loginResult->content); // -- ** -- Render result with twig if ($loginResult->isSuccess()) { return $twig->render('admin/pages/examples/invoice.html', $result); } else { return $twig->render('admin/pages/examples/invoice.html', $result); } }
public function testCommentCreation() { $c = new Config($this->container); $p = new Project($this->container); $tc = new TaskCreation($this->container); $cm = new Comment($this->container); $this->container['dispatcher']->addSubscriber(new WebhookSubscriber($this->container)); $c->save(array('webhook_url' => 'http://localhost/comment')); $this->assertEquals(1, $p->create(array('name' => 'test'))); $this->assertEquals(1, $tc->create(array('project_id' => 1, 'title' => 'test'))); $this->assertEquals(1, $cm->create(array('task_id' => 1, 'comment' => 'test comment', 'user_id' => 1))); $this->assertStringStartsWith('http://localhost/comment?token=', $this->container['httpClient']->getUrl()); $event = $this->container['httpClient']->getData(); $this->assertNotEmpty($event); $this->assertArrayHasKey('event_name', $event); $this->assertArrayHasKey('event_data', $event); $this->assertEquals('comment.create', $event['event_name']); $this->assertNotEmpty($event['event_data']); $this->assertArrayHasKey('task_id', $event['event_data']); $this->assertArrayHasKey('user_id', $event['event_data']); $this->assertArrayHasKey('comment', $event['event_data']); $this->assertArrayHasKey('id', $event['event_data']); $this->assertEquals('test comment', $event['event_data']['comment']); }
public function testUpdateActionGet() { $packageData = array('Name' => 'Name', 'Comment' => 'Comment', 'Platform' => 'Platform', 'DeployAction' => 'DeployAction', 'ActionParam' => 'ActionParam', 'Priority' => 'Priority', 'Warn' => 'Warn', 'WarnMessage' => 'WarnMessage', 'WarnCountdown' => 'WarnCountdown', 'WarnAllowAbort' => 'WarnAllowAbort', 'WarnAllowDelay' => 'WarnAllowDelay', 'PostInstMessage' => 'PostInstMessage'); $formData = array('Deploy' => array('Pending' => 'defaultDeployPending', 'Running' => 'defaultDeployRunning', 'Success' => 'defaultDeploySuccess', 'Error' => 'defaultDeployError', 'Groups' => 'defaultDeployGroups'), 'MaxFragmentSize' => 'defaultMaxFragmentSize'); $formData += $packageData; $this->_config->expects($this->exactly(6))->method('__get')->will($this->returnArgument(0)); $this->_updateForm->expects($this->once())->method('setData')->with($formData); $this->_updateForm->expects($this->never())->method('getData'); $this->_updateForm->expects($this->never())->method('isValid'); $this->_updateForm->expects($this->once())->method('render')->willReturn('<form></form>'); $this->_packageManager->expects($this->once())->method('getPackage')->with('oldName')->willReturn($packageData); $this->_packageManager->expects($this->never())->method('updatePackage'); $this->dispatch('/console/package/update/?name=oldName'); $this->assertResponseStatusCode(200); $this->assertXpathQuery('//form'); }
/** * Base tests for all _useform()-based actions (POST method, valid data) * * @param string $action "action" part of URI * @param string $formClass Form name without namespace */ protected function _testUseFormPostValid($action, $formClass) { $postData = array('Preferences' => array('pref1' => 'value1', 'pref2' => 'value2')); $form = $this->createMock("Console\\Form\\Preferences\\{$formClass}"); $form->expects($this->once())->method('setData')->with($postData); $form->expects($this->once())->method('getData')->willReturn($postData); $form->expects($this->once())->method('isValid')->willReturn(true); $form->expects($this->never())->method('render'); $this->_formManager->expects($this->once())->method('get')->with("Console\\Form\\Preferences\\{$formClass}")->will($this->returnValue($form)); $this->_config->expects($this->once())->method('setOptions')->with($this->callback(function ($options) { $options = iterator_to_array($options); return $options == array('pref1' => 'value1', 'pref2' => 'value2'); })); $this->dispatch("/console/preferences/{$action}", 'POST', $postData); $this->assertRedirectTo("/console/preferences/{$action}/"); }
public function index() { // -- ** -- GET Twig & city list $twig = Config::getTwig(); #$loginResult = ProductList::getAllProducts(); //die($_SERVER['REQUEST_URI']); $brands = Brand::getBrands(); $sections = Section::getSections(); if (Request::_request_post('product_name')) { $array["do"] = "addProduct"; if (Request::_request_post("product_brand")) { $array['brand_id'] = Request::_request_post("product_brand"); } $array['name'] = Request::_request_post("product_name"); if (Request::_request_post("product_code")) { $array['barcode'] = Request::_request_post("product_code"); } if (Request::_request_post("product_desc")) { $array['desc'] = Request::_request_post("product_desc"); } if (Request::_request_post("product_section")) { $array['section_id'] = Request::_request_post("product_section"); } if ($_FILES["product_image"]) { } else { echo "lkşkşki"; } $array["admin_id"] = "123459"; $res = ProductDetail::addProduct($array); if ($res->isSuccess()) { $result = array('addProductSuccess' => true, 'brands' => json_decode($brands)->content, 'sections' => json_decode($sections)->content); } else { $result = array('addProductFailure' => true, 'brands' => json_decode($brands)->content, 'sections' => json_decode($sections)->content); } return $twig->render('admin/pages/forms/general2.html', $result); } else { $prod = ProductList::getProduct(Request::_get("id")); if ($prod->isSuccess()) { $result = array('brands' => json_decode($brands)->content, 'sections' => json_decode($sections)->content, 'product' => $prod->content); } else { $result = array('brands' => json_decode($brands)->content, 'sections' => json_decode($sections)->content); } return $twig->render('admin/pages/forms/product.html', $result); } }
public function indexAction() { //生产环境禁止回调 return false; $action = \Comm\Arg::get('action', FILTER_DEFAULT, null, true); switch ($action) { //测试查询 case 'select': $db = new \Comm\Db\Simple('test'); $result = $db->limit(10)->fetchAll(); print_r($result); break; case 'config': print_r(\Model\Config::showAll()); break; } return false; }
public function testImportActionPostValidError() { $fileSpec = array('tmp_name' => 'uploaded_file'); $this->getRequest()->getFiles()->set('File', $fileSpec); $postData = array('key' => 'value'); $form = $this->_formManager->get('Console\\Form\\Import'); $form->expects($this->once())->method('isValid')->will($this->returnValue(true)); $form->expects($this->once())->method('setData')->with(array('File' => $fileSpec, 'key' => 'value')); $form->expects($this->once())->method('getData')->will($this->returnValue(array('File' => $fileSpec))); $form->expects($this->once())->method('render'); $this->_config->expects($this->once())->method('__get')->with('communicationServerUri')->will($this->returnValue('http://example.net/server')); $response = new \Zend\Http\Response(); $response->setStatusCode(500)->setReasonPhrase('reason_phrase'); $this->_inventoryUploader->expects($this->once())->method('uploadFile')->with('uploaded_file')->will($this->returnValue($response)); $this->dispatch('/console/client/import/', 'POST', $postData); $this->assertResponseStatusCode(200); $this->assertXpathQueryContentContains('//p[@class="error"]', "\nFehler beim Hochladen. Server http://example.net/server antwortete mit Fehler 500: reason_phrase\n"); $this->assertXpathQueryContentContains('//h1', "\nImport lokal erzeugter Inventardaten\n"); }
public function index() { // -- ** -- GET Twig & city list $twig = Config::getTwig(); if (isset($_POST["mail"]) && isset($_POST["pass"])) { $loginResult = User::login($_POST["mail"], $_POST["pass"]); //die($_SERVER['REQUEST_URI']); // -- ** -- Check $cityList content is exist with isset method $result = array('user' => $loginResult->content); // -- ** -- Render result with twig if ($loginResult->isSuccess()) { header("Location: index.php"); } else { return $twig->render('admin/pages/examples/login.html', $result); } } else { return $twig->render('admin/pages/examples/login.html', array()); } }
public function testGetWithSession() { $this->container['session'] = new Session(); $c = new Config($this->container); session_id('test'); $this->assertTrue(Session::isOpen()); $this->assertEquals('', $c->get('board_columns')); $this->assertEquals('test', $c->get('board_columns', 'test')); $this->container['session']['config'] = array('board_columns' => 'foo', 'empty_value' => 0); $this->assertEquals('foo', $c->get('board_columns')); $this->assertEquals('foo', $c->get('board_columns', 'test')); $this->assertEquals('test', $c->get('empty_value', 'test')); session_id(''); unset($this->container['session']); }