当前位置: 首页>>代码示例>>PHP>>正文


PHP di\Container类代码示例

本文整理汇总了PHP中PMA\libraries\di\Container的典型用法代码示例。如果您正苦于以下问题:PHP Container类的具体用法?PHP Container怎么用?PHP Container使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Container类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  */
 public function __construct()
 {
     $container = Container::getDefaultContainer();
     $this->container = $container;
     $this->dbi = $this->container->get('dbi');
     $this->response = $this->container->get('response');
 }
开发者ID:itgsod-philip-skalander,项目名称:phpmyadmin,代码行数:10,代码来源:Controller.php

示例2: testGetValuesForInnodbTable

 /**
  * Tests for getValuesForInnodbTable()
  *
  * @return void
  * @test
  */
 public function testGetValuesForInnodbTable()
 {
     $container = Container::getDefaultContainer();
     $container->set('db', 'db');
     $container->set('table', 'table');
     $container->set('dbi', $GLOBALS['dbi']);
     $response = new \PMA\Test\Stubs\Response();
     $container->set('PMA\\libraries\\Response', $response);
     $container->alias('response', 'PMA\\libraries\\Response');
     $class = new ReflectionClass('PMA\\libraries\\controllers\\database\\DatabaseStructureController');
     $method = $class->getMethod('getValuesForInnodbTable');
     $method->setAccessible(true);
     $ctrl = new DatabaseStructureController($GLOBALS['db'], null);
     // Showing statistics
     $property = $class->getProperty('_is_show_stats');
     $property->setAccessible(true);
     $property->setValue($ctrl, true);
     $GLOBALS['cfg']['MaxExactCount'] = 10;
     $current_table = array('ENGINE' => 'InnoDB', 'TABLE_ROWS' => 5, 'Data_length' => 16384, 'Index_length' => 0, 'TABLE_NAME' => 'table');
     list($current_table, , , $sum_size) = $method->invokeArgs($ctrl, array($current_table, 10));
     $this->assertEquals(true, $current_table['COUNTED']);
     $this->assertEquals(6, $current_table['TABLE_ROWS']);
     $this->assertEquals(16394, $sum_size);
     $current_table['ENGINE'] = 'MYISAM';
     list($current_table, , , $sum_size) = $method->invokeArgs($ctrl, array($current_table, 10));
     $this->assertEquals(false, $current_table['COUNTED']);
     $this->assertEquals(16394, $sum_size);
     // Not showing statistics
     $is_show_stats = false;
     $ctrl = new DatabaseStructureController($GLOBALS['db'], null);
     $current_table['ENGINE'] = 'InnoDB';
     list($current_table, , , $sum_size) = $method->invokeArgs($ctrl, array($current_table, 10));
     $this->assertEquals(true, $current_table['COUNTED']);
     $this->assertEquals(10, $sum_size);
     $current_table['ENGINE'] = 'MYISAM';
     list($current_table, , , $sum_size) = $method->invokeArgs($ctrl, array($current_table, 10));
     $this->assertEquals(false, $current_table['COUNTED']);
     $this->assertEquals(10, $sum_size);
 }
开发者ID:phpmyadmin,项目名称:phpmyadmin,代码行数:45,代码来源:DatabaseStructureControllerTest.php

示例3: testPMAGetPluginAndModuleInfo

 /**
  * Test for _getPluginsHtml() method
  *
  * @return void
  */
 public function testPMAGetPluginAndModuleInfo()
 {
     /**
      * Prepare plugin list
      */
     $row = array();
     $row["plugin_name"] = "plugin_name1";
     $row["plugin_type"] = "plugin_type1";
     $row["plugin_type_version"] = "plugin_version1";
     $row["plugin_author"] = "plugin_author1";
     $row["plugin_license"] = "plugin_license1";
     $row["plugin_description"] = "plugin_description1";
     $row["is_active"] = true;
     //Mock DBI
     $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock();
     $dbi->expects($this->once())->method('query')->will($this->returnValue(true));
     $dbi->expects($this->at(1))->method('fetchAssoc')->will($this->returnValue($row));
     $dbi->expects($this->at(2))->method('fetchAssoc')->will($this->returnValue(false));
     $dbi->expects($this->once())->method('freeResult')->will($this->returnValue(true));
     $container = Container::getDefaultContainer();
     $container->set('dbi', $dbi);
     $class = new ReflectionClass('\\PMA\\libraries\\controllers\\server\\ServerPluginsController');
     $method = $class->getMethod('_getPluginsHtml');
     $method->setAccessible(true);
     $ctrl = new ServerPluginsController();
     $html = $method->invoke($ctrl);
     //validate 1:Items
     $this->assertContains('<th>Plugin</th>', $html);
     $this->assertContains('<th>Description</th>', $html);
     $this->assertContains('<th>Version</th>', $html);
     $this->assertContains('<th>Author</th>', $html);
     $this->assertContains('<th>License</th>', $html);
     //validate 2: one Item HTML
     $this->assertContains('<th>plugin_name1</th>', $html);
     $this->assertContains('<td>plugin_description1</td>', $html);
     $this->assertContains('<td>plugin_version1</td>', $html);
     $this->assertContains('<td>plugin_author1</td>', $html);
     $this->assertContains('<td>plugin_license1</td>', $html);
 }
开发者ID:pboutin44,项目名称:maintest,代码行数:44,代码来源:ServerPluginsControllerTest.php

示例4: testGetHtmlForServerVariablesItems

 /**
  * Test for _getHtmlForServerVariablesItems()
  *
  * @return void
  */
 public function testGetHtmlForServerVariablesItems()
 {
     $class = new ReflectionClass('\\PMA\\libraries\\controllers\\server\\ServerVariablesController');
     $method = $class->getMethod('_getHtmlForServerVariablesItems');
     $method->setAccessible(true);
     $container = Container::getDefaultContainer();
     $container->factory('PMA\\libraries\\controllers\\server\\ServerVariablesController');
     $container->alias('ServerVariablesController', 'PMA\\libraries\\controllers\\server\\ServerVariablesController');
     $ctrl = $container->get('ServerVariablesController');
     $serverVarsSession = $GLOBALS['dbi']->fetchResult('SHOW SESSION VARIABLES;', 0, 1);
     $serverVars = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES;', 0, 1);
     $html = $method->invoke($ctrl, $serverVars, $serverVarsSession);
     //validate 1: variable: auto_increment_increment
     $name = "auto_increment_increment";
     $value = htmlspecialchars(str_replace('_', ' ', $name));
     $this->assertContains($value, $html);
     //validate 2: variable: auto_increment_offset
     $name = "auto_increment_offset";
     $value = htmlspecialchars(str_replace('_', ' ', $name));
     $this->assertContains($value, $html);
     $formatVariable = $class->getMethod('_formatVariable');
     $formatVariable->setAccessible(true);
     $args = array($name, "12");
     list($value, $isHtmlFormatted) = $formatVariable->invokeArgs($ctrl, $args);
     $this->assertContains($value, $html);
     //validate 3: variables
     $this->assertContains(__('Session value'), $html);
     $args = array($name, "13");
     list($value, $isHtmlFormatted) = $formatVariable->invokeArgs($ctrl, $args);
     $this->assertContains($value, $html);
 }
开发者ID:poush,项目名称:phpmyadmin,代码行数:36,代码来源:ServerVariablesControllerTest.php

示例5: isset

<?php

/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * Database structure manipulation
 *
 * @package PhpMyAdmin
 */
namespace PMA;

use PMA\libraries\controllers\database\DatabaseStructureController;
use PMA\libraries\Response;
use PMA\libraries\Util;
require_once 'libraries/common.inc.php';
require_once 'libraries/db_common.inc.php';
list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : '');
$container = libraries\di\Container::getDefaultContainer();
$container->factory('PMA\\libraries\\controllers\\database\\DatabaseStructureController');
$container->alias('DatabaseStructureController', 'PMA\\libraries\\controllers\\database\\DatabaseStructureController');
$container->set('PMA\\libraries\\Response', Response::getInstance());
$container->alias('response', 'PMA\\libraries\\Response');
global $db, $pos, $db_is_system_schema, $total_num_tables, $tables, $num_tables;
/* Define dependencies for the concerned controller */
$dependency_definitions = array('db' => $db, 'url_query' => &$GLOBALS['url_query'], 'pos' => $pos, 'db_is_system_schema' => $db_is_system_schema, 'num_tables' => $num_tables, 'total_num_tables' => $total_num_tables, 'tables' => $tables);
/** @var DatabaseStructureController $controller */
$controller = $container->get('DatabaseStructureController', $dependency_definitions);
$controller->indexAction();
开发者ID:itgsod-philip-skalander,项目名称:phpmyadmin,代码行数:27,代码来源:db_structure.php

示例6: elseif

            $extension = 'mysql';
            if (!PMA\libraries\DatabaseInterface::checkDbExtension($extension)) {
                // warn about both extensions missing and exit
                PMA_warnMissingExtension('mysqli|mysql', true, $doclink);
            } elseif (empty($_SESSION['mysqlwarning'])) {
                trigger_error(__('You are using the mysql extension which is deprecated in ' . 'phpMyAdmin. Please consider installing the mysqli ' . 'extension.') . ' ' . $doclink, E_USER_WARNING);
                // tell the user just once per session
                $_SESSION['mysqlwarning'] = true;
            }
        } else {
            // mysql extension is not part of PHP 7+, so warn and exit
            PMA_warnMissingExtension('mysqli', true, $doclink);
        }
    }
    /**
     * Including The DBI Plugin
     */
    switch ($extension) {
        case 'mysql':
            $extension = new DBIMysql();
            break;
        case 'mysqli':
            include_once 'libraries/dbi/DBIMysqli.lib.php';
            $extension = new DBIMysqli();
            break;
    }
}
$GLOBALS['dbi'] = new DatabaseInterface($extension);
$container = Container::getDefaultContainer();
$container->set('PMA_DatabaseInterface', $GLOBALS['dbi']);
$container->alias('dbi', 'PMA_DatabaseInterface');
开发者ID:netroby,项目名称:phpmyadmin,代码行数:31,代码来源:database_interface.inc.php

示例7: testGetDataRowAction

 /**
  * Tests for getDataRowAction()
  *
  * @return void
  * @test
  */
 public function testGetDataRowAction()
 {
     $meta_one = new stdClass();
     $meta_one->type = 'int';
     $meta_one->length = 11;
     $meta_two = new stdClass();
     $meta_two->length = 11;
     $meta_two->type = 'int';
     $fields_meta = array($meta_one, $meta_two);
     $GLOBALS['dbi']->expects($this->any())->method('getFieldsMeta')->will($this->returnValue($fields_meta));
     $GLOBALS['dbi']->expects($this->any())->method('fetchAssoc')->will($this->returnCallback(function () {
         static $count = 0;
         if ($count == 0) {
             $count++;
             return array('col1' => 1, 'col2' => 2);
         } else {
             return null;
         }
     }));
     $container = Container::getDefaultContainer();
     $container->set('dbi', $GLOBALS['dbi']);
     $container->factory('\\PMA\\libraries\\controllers\\Table\\TableSearchController');
     $container->alias('TableSearchController', 'PMA\\libraries\\controllers\\table\\TableSearchController');
     $ctrl = $container->get('TableSearchController');
     $_REQUEST['db'] = 'PMA';
     $_REQUEST['table'] = 'PMA_BookMark';
     $_REQUEST['where_clause'] = '`col1` = 1';
     $expected = array('col1' => 1, 'col2' => 2);
     $ctrl->getDataRowAction();
     $json = $this->response->getJSONResult();
     $this->assertEquals($expected, $json['row_info']);
 }
开发者ID:ryanfmurphy,项目名称:phpmyadmin,代码行数:38,代码来源:TableSearchController_test.php

示例8: testDisplayFormAction

 /**
  * Tests for displayFormAction()
  *
  * @return void
  * @test
  */
 public function testDisplayFormAction()
 {
     $table = $this->getMockBuilder('PMA\\libraries\\Table')->disableOriginalConstructor()->getMock();
     $table->expects($this->any())->method('getStatusInfo')->will($this->returnValue(""));
     $table->expects($this->any())->method('isView')->will($this->returnValue(false));
     $table->expects($this->any())->method('getNameAndTypeOfTheColumns')->will($this->returnValue(array("field_name" => "field_type")));
     $GLOBALS['dbi']->expects($this->any())->method('getTable')->will($this->returnValue($table));
     $container = Container::getDefaultContainer();
     $container->set('db', 'db');
     $container->set('table', 'table');
     $container->set('dbi', $GLOBALS['dbi']);
     $response = new \PMA\Test\Stubs\Response();
     $container->set('PMA\\libraries\\Response', $response);
     $container->alias('response', 'PMA\\libraries\\Response');
     $index = new PMA\libraries\Index();
     $ctrl = new TableIndexesController($index);
     $_REQUEST['create_index'] = true;
     $_REQUEST['added_fields'] = 3;
     $ctrl->displayFormAction();
     $html = $response->getHTMLResult();
     //PMA_URL_getHiddenInputs
     $this->assertContains(PMA_URL_getHiddenInputs(array('db' => 'db', 'table' => 'table', 'create_index' => 1)), $html);
     $doc_html = PMA\libraries\Util::showHint(PMA\libraries\Message::notice(__('"PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!')));
     $this->assertContains($doc_html, $html);
     $this->assertContains(PMA\libraries\Util::showMySQLDocu('ALTER_TABLE'), $html);
     // generateIndexSelector
     $this->assertContains(PMA\libraries\Template::trim($index->generateIndexChoiceSelector(false)), $html);
     $this->assertContains(sprintf(__('Add %s column(s) to index'), 1), $html);
     //$field_name & $field_type
     $this->assertContains("field_name", $html);
     $this->assertContains("field_type", $html);
 }
开发者ID:pjiahao,项目名称:phpmyadmin,代码行数:38,代码来源:TableIndexesControllerTest.php

示例9: testPMAGetDataForSubmitMult

 /**
  * Test for getDataForSubmitMult()
  *
  * @return void
  * @test
  */
 public function testPMAGetDataForSubmitMult()
 {
     $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock();
     $dbi->expects($this->any())->method('query')->will($this->returnValue(true));
     $class = new ReflectionClass('PMA\\libraries\\controllers\\tableStructureController');
     $method = $class->getMethod('getDataForSubmitMult');
     $method->setAccessible(true);
     $container = Container::getDefaultContainer();
     $container->set('dbi', $dbi);
     $container->factory('PMA\\libraries\\controllers\\tableStructureController');
     $container->alias('TableStructureController', 'PMA\\libraries\\controllers\\tableStructureController');
     $ctrl = $container->get('TableStructureController');
     $submit_mult = "index";
     $db = "PMA_db";
     $table = "PMA_table";
     $selected = array("table1", "table2");
     $action = 'db_delete_row';
     list($what, $query_type, $is_unset_submit_mult, $mult_btn, $centralColsError) = $method->invokeArgs($ctrl, array($submit_mult, $db, $table, $selected, $action));
     //validate 1: $what
     $this->assertEquals(null, $what);
     //validate 2: $query_type
     $this->assertEquals('index_fld', $query_type);
     //validate 3: $is_unset_submit_mult
     $this->assertEquals(true, $is_unset_submit_mult);
     //validate 4:
     $this->assertEquals(__('Yes'), $mult_btn);
     //validate 5: $centralColsError
     $this->assertEquals(null, $centralColsError);
     $submit_mult = "unique";
     list($what, $query_type, $is_unset_submit_mult, $mult_btn, $centralColsError) = $method->invokeArgs($ctrl, array($submit_mult, $db, $table, $selected, $action));
     //validate 1: $what
     $this->assertEquals(null, $what);
     //validate 2: $query_type
     $this->assertEquals('unique_fld', $query_type);
     //validate 3: $is_unset_submit_mult
     $this->assertEquals(true, $is_unset_submit_mult);
     //validate 4: $mult_btn
     $this->assertEquals(__('Yes'), $mult_btn);
     //validate 5: $centralColsError
     $this->assertEquals(null, $centralColsError);
 }
开发者ID:netroby,项目名称:phpmyadmin,代码行数:47,代码来源:TableStructureControllerTest.php

示例10: testGetColumnOrder

 /**
  * Tests for _getColumnOrder()
  *
  * @return void
  */
 public function testGetColumnOrder()
 {
     $class = new ReflectionClass('\\PMA\\libraries\\controllers\\server\\ServerDatabasesController');
     $method = $class->getMethod('_getColumnOrder');
     $method->setAccessible(true);
     $container = Container::getDefaultContainer();
     $container->factory('PMA\\libraries\\controllers\\server\\ServerDatabasesController');
     $container->alias('ServerDatabasesController', 'PMA\\libraries\\controllers\\server\\ServerDatabasesController');
     $ctrl = $container->get('ServerDatabasesController');
     $this->assertEquals(array('DEFAULT_COLLATION_NAME' => array('disp_name' => __('Collation'), 'description_function' => 'PMA_getCollationDescr', 'format' => 'string', 'footer' => 'utf8_general_ci'), 'SCHEMA_TABLES' => array('disp_name' => __('Tables'), 'format' => 'number', 'footer' => 0), 'SCHEMA_TABLE_ROWS' => array('disp_name' => __('Rows'), 'format' => 'number', 'footer' => 0), 'SCHEMA_DATA_LENGTH' => array('disp_name' => __('Data'), 'format' => 'byte', 'footer' => 0), 'SCHEMA_INDEX_LENGTH' => array('disp_name' => __('Indexes'), 'format' => 'byte', 'footer' => 0), 'SCHEMA_LENGTH' => array('disp_name' => __('Total'), 'format' => 'byte', 'footer' => 0), 'SCHEMA_DATA_FREE' => array('disp_name' => __('Overhead'), 'format' => 'byte', 'footer' => 0)), $method->invoke($ctrl));
 }
开发者ID:Stony-Brook-University,项目名称:doitsbu,代码行数:16,代码来源:ServerDatabasesControllerTest.php

示例11: testGetDropdownValueForDbActionTwo

 /**
  * Tests for getDropdownValueForDbAction()
  *
  * Case two: not foreign
  *
  * @return void
  * @test
  */
 public function testGetDropdownValueForDbActionTwo()
 {
     $GLOBALS['dbi']->expects($this->any())->method('fetchArray')->will($this->returnCallback(function () {
         static $count = 0;
         if ($count == 0) {
             $count++;
             return array('table');
         }
         return null;
     }));
     $container = Container::getDefaultContainer();
     $container->set('dbi', $GLOBALS['dbi']);
     $container->factory('PMA\\libraries\\controllers\\table\\TableRelationController');
     $container->alias('TableRelationController', 'PMA\\libraries\\controllers\\table\\TableRelationController');
     $ctrl = $container->get('TableRelationController', array('tbl_storage_engine' => 'INNODB'));
     $_REQUEST['foreign'] = 'false';
     $ctrl->getDropdownValueForDbAction();
     $json = $this->_response->getJSONResult();
     $this->assertEquals(array('table'), $json['tables']);
 }
开发者ID:pboutin44,项目名称:maintest,代码行数:28,代码来源:TableRelationControllerTest.php

示例12: testGetAllLogItemInfo

 /**
  * Tests for _getAllLogItemInfo
  *
  * @return void
  */
 public function testGetAllLogItemInfo()
 {
     $class = new ReflectionClass('\\PMA\\libraries\\controllers\\server\\ServerBinlogController');
     $method = $class->getMethod('_getAllLogItemInfo');
     $method->setAccessible(true);
     $ctrl = new ServerBinlogController();
     //Mock DBI
     $container = Container::getDefaultContainer();
     $dbi = $container->get('dbi');
     $fetchAssoc = array('Info' => 'Info', 'Log_name' => 'Log_name', 'Pos' => 'Pos', 'Event_type' => 'Event_type', 'Server_id' => 'Server_id', 'Orig_log_pos' => 'Orig_log_pos', 'End_log_pos' => 'End_log_pos');
     $dbi->expects($this->at(0))->method('fetchAssoc')->will($this->returnValue($fetchAssoc));
     $dbi->expects($this->at(1))->method('fetchAssoc')->will($this->returnValue(false));
     $container->set('dbi', $dbi);
     $GLOBALS['cfg']['LimitChars'] = 2;
     $result = array();
     $dontlimitchars = ";";
     $html = $method->invoke($ctrl, $result, $dontlimitchars);
     $value = $fetchAssoc;
     $this->assertContains($value['Log_name'], $html);
     $this->assertContains($value['Pos'], $html);
     $this->assertContains($value['Event_type'], $html);
     $this->assertContains($value['Server_id'], $html);
     $this->assertContains($value['Orig_log_pos'], $html);
     $this->assertContains(htmlspecialchars($value['Info']), $html);
 }
开发者ID:pboutin44,项目名称:maintest,代码行数:30,代码来源:ServerBinlogControllerTest.php

示例13: array_merge

    $form_params['orig_num_fields'] = $num_fields;
}
$form_params = array_merge($form_params, array('orig_field_where' => Util\get($_REQUEST, 'field_where'), 'orig_after_field' => Util\get($_REQUEST, 'after_field')));
if (isset($selected) && is_array($selected)) {
    foreach ($selected as $o_fld_nr => $o_fld_val) {
        $form_params['selected[' . $o_fld_nr . ']'] = $o_fld_val;
    }
}
$is_backup = $action != 'tbl_create.php' && $action != 'tbl_addfield.php';
require_once './libraries/transformations.lib.php';
$cfgRelation = PMA_getRelationsParam();
$comments_map = PMA_getComments($db, $table);
$move_columns = array();
if (isset($fields_meta)) {
    /** @var PMA\libraries\DatabaseInterface $dbi */
    $dbi = \PMA\libraries\di\Container::getDefaultContainer()->get('dbi');
    $move_columns = $dbi->getTable($db, $table)->getColumnsMeta();
}
$available_mime = array();
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
    $mime_map = PMA_getMIME($db, $table);
    $available_mime = PMA_getAvailableMIMEtypes();
}
//  workaround for field_fulltext, because its submitted indices contain
//  the index as a value, not a key. Inserted here for easier maintenance
//  and less code to change in existing files.
if (isset($field_fulltext) && is_array($field_fulltext)) {
    foreach ($field_fulltext as $fulltext_nr => $fulltext_indexkey) {
        $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
    }
}
开发者ID:pboutin44,项目名称:maintest,代码行数:31,代码来源:tbl_columns_definition_form.inc.php


注:本文中的PMA\libraries\di\Container类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。