本文整理汇总了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;
}
示例2: setUp
public function setUp()
{
parent::setUp();
$this->Controller = new EnummPostsController();
$collection = new ComponentCollection();
$collection->init($this->Controller);
}
示例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;
}
示例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);
}
示例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;
}
示例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);
}
示例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/*');
}
示例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/*');
}
示例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'));
}
示例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']);
}
示例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);
}
示例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);
}
示例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) . '"'));
}
示例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))));
}
示例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));
}