本文整理汇总了PHP中Phake::partialMock方法的典型用法代码示例。如果您正苦于以下问题:PHP Phake::partialMock方法的具体用法?PHP Phake::partialMock怎么用?PHP Phake::partialMock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phake
的用法示例。
在下文中一共展示了Phake::partialMock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
$this->pdo = Phake::partialMock('PDO', $_ENV['MySQL_Store_DSN'], $_ENV['MySQL_Store_User'], $_ENV['MySQL_Store_Password']);
$this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->pdo->exec('SET foreign_key_checks = 0');
$this->pdo->exec('CREATE DATABASE IF NOT EXISTS `machinist_test`;');
$this->pdo->exec('USE `machinist_test`;');
$this->pdo->exec('DROP TABLE IF EXISTS `stuff`;');
$this->pdo->exec('create table `stuff` ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, `name` varchar(100) );');
$this->pdo->exec('DROP TABLE IF EXISTS `some_stuff`;');
$this->pdo->exec('CREATE TABLE `some_stuff` (
`some_id` int(10) unsigned NOT NULL,
`stuff_id` int(10) unsigned NOT NULL,
`name` VARCHAR(100),
PRIMARY KEY (`some_id`,`stuff_id`));');
$this->pdo->exec('DROP TABLE IF EXISTS `group`;');
$this->pdo->exec('create table `group` ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, `name` VARCHAR(255));');
$this->pdo->exec('DROP TABLE IF EXISTS `nopk`;');
$this->pdo->exec('create table `nopk` ( `id` INTEGER, `name` VARCHAR(255));');
$this->pdo->exec('DROP TABLE IF EXISTS `fkey`;');
$this->pdo->exec('CREATE TABLE `fkey`
( `id` int(11) NOT NULL AUTO_INCREMENT,
`stuff_id` int(11),
PRIMARY KEY (`id`),
KEY `IDX_1` (`stuff_id`),
CONSTRAINT `FK_1` FOREIGN KEY (`stuff_id`) REFERENCES `stuff` (`id`)
) ENGINE=InnoDB');
$this->pdo->exec('SET foreign_key_checks = 1');
$this->driver = SqlStore::fromPdo($this->pdo);
}
示例2: setUp
public function setUp()
{
$this->connection = \Phake::mock('\\mysqli');
$this->statement = \Phake::mock('\\Hoimi\\Session\\StatementDummy');
$this->target = \Phake::partialMock('Hoimi\\Session\\DatabaseDriver', new Config());
$this->target->setConnection($this->connection);
}
示例3: getScreen
/**
* For some reason setUp nor setUpBeforeClass would create the requested object
*
* @return Screen
*/
protected function getScreen()
{
if (empty($this->screen) === true) {
$this->screen = Phake::partialMock('Arjf\\Devices\\Handheld\\Apple\\Screen', 320, 480);
}
return $this->screen;
}
示例4: callProtectedMusicAPI
protected function callProtectedMusicAPI($call_fn, $expected_url_extension, $expected_params = [], $sample_response = null)
{
if ($sample_response === null) {
$sample_response = ['foo' => 'bar'];
}
$generator = new Generator();
// set up the mock to check headers generated
$tokenly_api = Phake::partialMock('Tokenly\\APIClient\\TokenlyAPI', 'https://127.0.0.1/api/v1', $generator, 'MY_CLIENT_ID', 'MY_CLIENT_SECRET');
$called_vars = [];
Phake::when($tokenly_api)->callRequest(Phake::anyParameters())->thenReturnCallback(function ($url, $headers, $request_params, $method, $request_options) use($sample_response, &$called_vars) {
$called_vars = [];
$response = new Requests_Response();
$response->body = json_encode($sample_response);
$called_vars['headers'] = $headers;
$called_vars['url'] = $url;
$called_vars['params'] = $request_params;
return $response;
});
$music_api = new MusicAPI($tokenly_api);
// check API call
$result = $call_fn($music_api);
PHPUnit::assertEquals($sample_response, $result);
// check called URL
PHPUnit::assertEquals('https://127.0.0.1/api/v1/' . $expected_url_extension, $called_vars['url']);
// check headers
$headers_generated = $called_vars['headers'];
PHPUnit::assertNotEmpty($headers_generated);
$nonce = $headers_generated['X-TOKENLY-AUTH-NONCE'];
PHPUnit::assertGreaterThanOrEqual(time(), $nonce);
PHPUnit::assertEquals('MY_CLIENT_ID', $headers_generated['X-TOKENLY-AUTH-API-TOKEN']);
$expected_signature = $this->expectedSignature($nonce, 'https://127.0.0.1/api/v1/' . $expected_url_extension, $expected_params);
PHPUnit::assertEquals($expected_signature, $headers_generated['X-TOKENLY-AUTH-SIGNATURE']);
// return the called vars
return $called_vars;
}
示例5: setUp
public function setUp()
{
$this->target = \Phake::partialMock('Mahotora\\DatabaseSessionImpl', array());
$this->connection = \Phake::mock('\\mysqli');
$this->statement = \Phake::mock('\\mysqli_stmt');
$this->resultSet = \Phake::mock('\\mysqli_result');
$this->target->setConnection($this->connection);
}
示例6: mockProxyServer
/**
* @return EngineBlock_Corto_ProxyServer
*/
private function mockProxyServer()
{
// Mock proxy server
$_SERVER['HTTP_HOST'] = 'test-host';
/** @var EngineBlock_Corto_ProxyServer $proxyServerMock */
$proxyServerMock = Phake::partialMock('EngineBlock_Corto_ProxyServer');
$proxyServerMock->setRepository(new InMemoryMetadataRepository(array(), array(new ServiceProvider('https://sp.example.edu'))))->setBindingsModule($this->mockBindingsModule());
return $proxyServerMock;
}
示例7: setUP
public function setUP()
{
$this->app = \Phake::partialMock('Dbup\\Application');
$this->pdo = \Phake::mock('Dbup\\Database\\PdoDatabase');
$this->dbh = \Phake::mock('\\Pdo');
\Phake::when($this->pdo)->connection(\Phake::anyParameters())->thenReturn($this->dbh);
$this->stmt = \Phake::mock('\\PDOStatement');
\Phake::when($this->dbh)->prepare(\Phake::anyParameters())->thenReturn($this->stmt);
}
示例8: setUp
public function setUp()
{
$this->next = \Phake::mock('\\Moshas\\Pipe');
$this->entity = new Entity();
$this->entity2 = new Entity();
$this->entity3 = new Entity();
$this->target = \Phake::partialMock('\\Moshas\\Pipe', $this->next);
$this->lastTarget = \Phake::partialMock('\\Moshas\\Pipe');
}
示例9: setUp
public function setUp()
{
$this->client = \Phake::mock('\\Moshas\\Twitter\\TwitterClient');
$this->target = \Phake::partialMock('\\Moshas\\Twitter\\StatusPager', $this->client);
\Phake::when($this->target)->buildUrl()->thenReturn('/url');
\Phake::when($this->target)->buildQuery(null)->thenReturn(array('a' => 'b'));
\Phake::when($this->target)->buildQuery(1233)->thenReturn(array('c' => 'd'));
\Phake::when($this->client)->get('/url', array('a' => 'b'))->thenReturn((object) array('statuses' => array((object) array('id' => 1234, 'text' => 'hoge', 'created_at' => '2015-01-01 12:34', 'id_str' => '1234', 'user' => (object) array('screen_name' => 't_ishida', 'profile_image_url_https' => 'https://url/path/img.jpg')))));
\Phake::when($this->client)->get('/url', array('c' => 'd'))->thenReturn((object) array('statuses' => array()));
}
示例10: testErrorAPICall
/**
* @expectedException Tokenly\APIClient\Exception\APIException
* @expectedExceptionMessage Sample error
*/
public function testErrorAPICall()
{
$api = Phake::partialMock('Tokenly\\APIClient\\TokenlyAPI', 'https://127.0.0.1/api/v1');
Phake::when($api)->callRequest(Phake::anyParameters())->thenReturnCallback(function ($url, $headers, $body, $method, $options) {
$response = new Requests_Response();
$response->body = json_encode(['error' => 'Sample error']);
return $response;
});
$api->call('POST', 'method/witherror', ['foo' => 'bar']);
}
示例11: setUp
protected function setUp()
{
parent::setUp();
$this->tmpDirectory = __DIR__;
$this->junitXMLFile = $this->tmpDirectory . '/' . $this->getName(false) . '.xml';
$legacyProxy = \Phake::partialMock('Stagehand\\TestRunner\\Util\\LegacyProxy');
\Phake::when($legacyProxy)->ob_get_level()->thenReturn(0);
\Phake::when($legacyProxy)->system($this->anything(), $this->anything())->thenReturn(null);
$this->setComponent('legacy_proxy', $legacyProxy);
$this->configure();
}
示例12: testSpecificSqlFile
public function testSpecificSqlFile()
{
$application = \Phake::partialMock('Dbup\\Application');
/** want not to run, so change up method to mock */
\Phake::when($application)->up(\Phake::anyParameters())->thenReturn(null);
$application->add(new UpCommand());
$command = $application->find('up');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), '--ini' => __DIR__ . '/../.dbup/properties.ini.test', 'file' => 'V12__sample12_select.sql']);
\Phake::verify($application, \Phake::times(1))->up(\Phake::anyParameters());
}
示例13: should_load_proper_segment_config
/** @test */
public function should_load_proper_segment_config()
{
$mappingDir = realpath(__DIR__ . '/../../src/EDI/Mapping');
/** @var MappingLoader $loader */
$loader = \Phake::partialMock(MappingLoader::class, $mappingDir);
$segmentPopulator = $this->givenSegmentPopulator();
$populator = $this->givenPopulator($segmentPopulator, $loader);
$fixtureDir = realpath(__DIR__ . '/../fixtures');
$parser = new Parser();
$data = $parser->parse($fixtureDir . '/invoic_message_standalone.edi');
$populator->populate($data);
\Phake::verify($loader)->loadMessage('D', '96A', 'INVOIC');
}
示例14: mockProxyServer
/**
* @return EngineBlock_Corto_ProxyServer
*/
private function mockProxyServer()
{
// Mock proxy server
/** @var EngineBlock_Corto_ProxyServer $proxyServerMock */
$proxyServerMock = Phake::partialMock('EngineBlock_Corto_ProxyServer');
$proxyServerMock->setHostname('test-host');
$proxyServerMock->setRepository(new InMemoryMetadataRepository(array(new IdentityProvider('testIdP')), array(new ServiceProvider('testSp'))));
$bindingsModuleMock = $this->mockBindingsModule();
$proxyServerMock->setBindingsModule($bindingsModuleMock);
Phake::when($proxyServerMock)->renderTemplate(Phake::anyParameters())->thenReturn(null);
Phake::when($proxyServerMock)->sendOutput(Phake::anyParameters())->thenReturn(null);
return $proxyServerMock;
}
示例15: testCreate
public function testCreate()
{
$application = \Phake::partialMock('Dbup\\Application');
$application->add(new CreateCommand());
$command = $application->find('create');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'name' => 'foo', '--ini' => __DIR__ . '/../.dbup/properties.ini.test']);
$display = $commandTester->getDisplay();
assertThat($display, is(containsString('created')));
preg_match('/\'(.+)\'/', $display, $matches);
assertThat(1, count($matches));
$migration = str_replace("'", "", $matches[0]);
unlink(__DIR__ . '/../../../' . $migration);
}