當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ComponentCollection::init方法代碼示例

本文整理匯總了PHP中ComponentCollection::init方法的典型用法代碼示例。如果您正苦於以下問題:PHP ComponentCollection::init方法的具體用法?PHP ComponentCollection::init怎麽用?PHP ComponentCollection::init使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ComponentCollection的用法示例。


在下文中一共展示了ComponentCollection::init方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: generateComponent

 /**
  * Generates the component for test
  * Options:
  * - mocks: specify mock methods for each objects
  * - componentOptopns: could be used for component options.
  *
  * @param $options
  * @return void
  */
 public function generateComponent($options = [])
 {
     $options = Hash::merge(['mocks' => ['controller' => ['_stop', 'redirect']], 'componentOptions' => ['setDebuggerTypeAs' => false, 'setExceptionHandler' => false, 'setAuthenticate' => false], 'initialize' => true], $options);
     extract($options);
     $this->request = $this->getMockBuilder('CakeRequest')->setConstructorArgs(['/', false])->setMethods(Hash::get($mocks, 'request'))->getMock();
     $this->response = $this->getMockBuilder('CakeResponse')->setMethods(Hash::get($mocks, 'response'))->getMock();
     $this->controller = $this->getMockBuilder('Controller')->setConstructorArgs([$this->request, $this->response])->setMethods(Hash::get($mocks, 'controller'))->getMock();
     $this->collection = $this->getMockBuilder('ComponentCollection')->setMethods(Hash::get($mocks, 'collection'))->getMock();
     $this->collection->init($this->controller);
     $this->Api = $this->getMockBuilder('ApiComponent')->setConstructorArgs([$this->collection, $componentOptions])->setMethods(Hash::get($mocks, 'Api'))->getMock();
     if ($initialize) {
         $this->Api->initialize($this->controller);
     }
     return $this->Api;
 }
開發者ID:hiromi2424,項目名稱:api,代碼行數:24,代碼來源:ApiComponentTest.php

示例2: setUp

 public function setUp()
 {
     parent::setUp();
     $this->Controller = new EnummPostsController();
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
 }
開發者ID:k1low,項目名稱:enumm,代碼行數:7,代碼來源:EnummComponentTest.php

示例3: setUp

 public function setUp()
 {
     $this->Controller = $this->getMock('AccessLimitTestController', array('dispatchMethod'), array($this->getMock('CakeRequest', array('is'), array(null, false)), $this->getMock('CakeResponse')));
     $this->Model = $this->getMockForModel('Security.AccessLimit');
     ClassRegistry::addObject('AccessLimit', $this->Model);
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Controller->Components->init($this->Controller);
     $this->AccessLimit = $this->Controller->AccessLimit;
 }
開發者ID:gourmet,項目名稱:security,代碼行數:10,代碼來源:AccessLimitComponentTest.php

示例4: setUp

 public function setUp()
 {
     parent::setUp();
     $request = new CakeRequest(null, false);
     $request->params['ext'] = 'json';
     $this->Controller = new TestRestController($request, $this->getMock('CakeResponse'));
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Rest = new MockRestComponent($collection, $this->settings);
     $this->Rest->request = $request;
     $this->Rest->response = $this->getMock('CakeResponse');
     $this->Controller->Components->init($this->Controller);
 }
開發者ID:kvz,項目名稱:cakephp-rest-plugin,代碼行數:13,代碼來源:RestComponentTest.php

示例5: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $request = new CakeRequest(null, false);
     $this->Controller = new UploaderTestController($request, $this->getMock('CakeResponse'));
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Uploader = new TestUploaderComponent($collection);
     $this->Controller->Components->init($this->Controller);
     $this->Controller->startupProcess();
     $this->upload1 = array('name' => 'Upload.jpg', 'type' => 'image/jpg', 'tmp_name' => $this->tmpDir . 'upload.jpg', 'error' => (int) 0, 'size' => filesize($this->tmpDir . 'upload.jpg'));
     $this->upload2 = array('name' => 'Upload File 2.txt', 'type' => 'text/plain', 'tmp_name' => $this->tmpDir . 'upload2.txt', 'error' => (int) 0, 'size' => filesize($this->tmpDir . 'upload2.txt'));
     $this->MediaUpload = ClassRegistry::init('MediaUpload');
     $this->Controller->Uploader->setModel($this->MediaUpload);
     $this->uploadResult = null;
 }
開發者ID:fm-labs,項目名稱:cakephp-media,代碼行數:21,代碼來源:UploaderComponentTest.php

示例6: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     // Ensure all requests start with a valid token attached.
     $token = 'cc0a91cfa4f3b703531c1dc4f5f64b89';
     $request = $this->getMock('CakeRequest', array('header'), array(null, false));
     $request->staticExpects($this->any())->method('header')->with('Authorization')->will($this->returnValue('Bearer ' . $token));
     $this->Controller = new StatelessAuthController($request, $this->getMock('CakeResponse'));
     $this->Controller->request = $request;
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Component = new TestStatelessAuthComponent($collection);
     $this->Component->request = $request;
     $this->Component->response = $this->getMock('CakeResponse');
     $this->Controller->Components->init($this->Controller);
 }
開發者ID:loadsys,項目名稱:cakephp-stateless-auth,代碼行數:21,代碼來源:StatelessAuthComponentTest.php

示例7: setUp

 public function setUp()
 {
     parent::setUp();
     // コンポーネントと偽のテストコントローラをセットアップする
     $request = new CakeRequest();
     $response = $this->getMock('CakeResponse');
     $this->Controller = new BcReplacePrefixTestController($request, $response);
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->BcReplacePrefix = new BcReplacePrefixComponent($collection);
     $this->BcReplacePrefix->request = $request;
     $this->BcReplacePrefix->response = $response;
     $this->Controller->Components->init($this->Controller);
     Router::reload();
     Router::connect('/:controller/:action/*');
 }
開發者ID:baserproject,項目名稱:basercms,代碼行數:16,代碼來源:BcReplacePrefixComponentTest.php

示例8: setUp

 public function setUp()
 {
     @session_start();
     parent::setUp();
     // コンポーネントと偽のコントローラをセットアップする
     $request = new CakeRequest();
     $response = $this->getMock('CakeResponse');
     $this->Controller = new BcAuthConfigureTestController($request, $response);
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->BcAuthConfigure = new BcAuthConfigureComponent($collection);
     $this->BcAuthConfigure->request = $request;
     $this->BcAuthConfigure->response = $response;
     $this->Controller->Components->init($this->Controller);
     Router::reload();
     Router::connect('/:controller/:action/*');
 }
開發者ID:baserproject,項目名稱:basercms,代碼行數:17,代碼來源:BcAuthConfigureComponentTest.php

示例9: testConstructionMissing

 public function testConstructionMissing()
 {
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->setExpectedException('PermitException');
     $testPermit = new TestPermitComponent($collection, array('path' => 'MockAuthTest', 'check' => 'id', 'isTest' => false, 'permit_include_path' => dirname(__FILE__) . DS . 'Config' . DS . 'permit.php'));
 }
開發者ID:superstarrajini,項目名稱:cakepackages,代碼行數:7,代碼來源:PermitTest.php

示例10: testConstructorSettings

 /**
  * Test that the constructor sets the settings.
  *
  * @return void
  */
 public function testConstructorSettings()
 {
     $settings = array('ajaxLayout' => 'test_ajax', 'viewClassMap' => array('json' => 'MyPlugin.MyJson'));
     $Collection = new ComponentCollection();
     $Collection->init($this->Controller);
     $RequestHandler = new RequestHandlerComponent($Collection, $settings);
     $this->assertEquals('test_ajax', $RequestHandler->ajaxLayout);
     $this->assertEquals(array('json' => 'MyPlugin.MyJson'), $RequestHandler->settings['viewClassMap']);
 }
開發者ID:saihe,項目名稱:reservation,代碼行數:14,代碼來源:RequestHandlerComponentTest.php

示例11: testConstructorSettings

 /**
  * Test that the constructor sets the settings.
  *
  * @return void
  */
 public function testConstructorSettings()
 {
     $settings = array('ajaxLayout' => 'test_ajax');
     $Collection = new ComponentCollection();
     $Collection->init($this->Controller);
     $RequestHandler = new RequestHandlerComponent($Collection, $settings);
     $this->assertEquals('test_ajax', $RequestHandler->ajaxLayout);
 }
開發者ID:pkdevbox,項目名稱:app.director,代碼行數:13,代碼來源:RequestHandlerComponentTest.php

示例12: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $CakeRequest = new CakeRequest(null, false);
     $CakeResponse = $this->getMock('CakeResponse', array('send'));
     $this->Controller = new WizardTestController($CakeRequest, $CakeResponse);
     $ComponentCollection = new ComponentCollection();
     $ComponentCollection->init($this->Controller);
     $this->Controller->Components->init($this->Controller);
     $this->Wizard = $this->Controller->Wizard;
     $this->Wizard->initialize($this->Controller);
 }
開發者ID:proloser,項目名稱:cakephp-wizard,代碼行數:17,代碼來源:WizardComponentTest.php

示例13: setUp

 /**
  * setUp method
  *
  * @access public
  * @return void
  */
 function setUp()
 {
     parent::setUp();
     $this->_server = $_SERVER;
     $this->_env = $_ENV;
     Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
     Configure::write('Security.cipherSeed', 770011223369876.0);
     $request = new CakeRequest(null, false);
     $this->Controller = new AuthTestController($request);
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Auth = new TestAuthComponent($collection);
     $this->Auth->request = $request;
     $this->Auth->response = $this->getMock('CakeResponse');
     $this->Controller->Components->init($this->Controller);
     $this->initialized = true;
     Router::reload();
     ClassRegistry::init('AuthUser')->updateAll(array('password' => '"' . Security::hash('cake', null, true) . '"'));
 }
開發者ID:robotarmy,項目名稱:Phog,代碼行數:25,代碼來源:auth.test.php

示例14: setUp

 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     Configure::write('Security.salt', 'YJfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
     Configure::write('Security.cipherSeed', 770011223369876);
     $request = new CakeRequest(null, false);
     $this->Controller = new AuthTestController($request, $this->getMock('CakeResponse'));
     $collection = new ComponentCollection();
     $collection->init($this->Controller);
     $this->Auth = new TestAuthComponent($collection);
     $this->Auth->request = $request;
     $this->Auth->response = $this->getMock('CakeResponse');
     $this->Controller->Components->init($this->Controller);
     $this->initialized = true;
     Router::reload();
     Router::connect('/:controller/:action/*');
     $User = ClassRegistry::init('AuthUser');
     $User->updateAll(array('password' => $User->getDataSource()->value(Security::hash('cake', null, true))));
 }
開發者ID:julkar9,項目名稱:gss,代碼行數:24,代碼來源:AuthComponentTest.php

示例15: testInitializeWithAppErrorController

 /**
  * Test initialize with AppError controller
  *
  * @author  Everton Yoshitani <everton@wizehive.com>
  * @since   1.0
  * @return  void
  */
 public function testInitializeWithAppErrorController()
 {
     $Controller = new Controller();
     $Controller->name = 'AppError';
     $Collection = new ComponentCollection();
     $Collection->init($Controller);
     $Component = $this->getMock('Component', array('getController'), array($Collection));
     $ApiPhpAcl = new ApiPhpAcl($Component);
     $this->assertTrue($ApiPhpAcl->initialize($Component));
 }
開發者ID:manzapanza,項目名稱:cakephp-api-utils,代碼行數:17,代碼來源:ApiPhpAclTest.php


注:本文中的ComponentCollection::init方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。