本文整理汇总了PHP中Object::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP Object::shouldReceive方法的具体用法?PHP Object::shouldReceive怎么用?PHP Object::shouldReceive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Object
的用法示例。
在下文中一共展示了Object::shouldReceive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_deactivateFail
/**
* Test a failing deactivate
*
* @return void
* @author Dan Cox
*/
public function test_deactivateFail()
{
$this->modules->shouldReceive('deactivate')->with('test')->andThrow("Exception");
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName(), 'name' => 'test']);
$this->assertContains('Failed to deactivate', $CT->getDisplay());
}
示例2: test_updateProjectsFromScan
/**
* Test updating existing projects
*
* @return void
* @author Dan Cox
*/
public function test_updateProjectsFromScan()
{
$this->DI->addMock('finder', $this->finder);
$this->DI->addMock('config', $this->config);
$this->DI->addMock('database', $this->database);
$this->finder->shouldReceive('files')->andReturn($this->finder);
$this->finder->shouldReceive('in')->andReturn([$this->finder]);
$this->finder->shouldReceive('getRealPath')->andReturn('/var/www/test/test.yml');
$this->config->shouldReceive('load')->with('/var/www/test/test.yml')->andReturn($this->config);
$this->config->shouldReceive('params')->andReturn($this->config);
$this->config->name = 'project';
$this->config->description = '';
$this->config->root_development = '';
$this->config->root_live = '';
$this->config->repository = array('remote_url' => '');
$this->database->shouldReceive('getEntity')->andReturn($this->database);
$this->database->shouldReceive('setModel');
$this->database->shouldReceive('count')->with(['name', '=', 'project'])->andReturn(1);
$this->database->shouldReceive('first')->andReturn($this->database);
$this->database->repository = $this->database;
$this->database->shouldReceive('save');
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName()]);
$this->assertContains('Successfully saved project: project', $CT->getDisplay());
$this->assertContains('Finished processing project file changes', $CT->getDisplay());
}
示例3: test_fail
/**
* Test a fail to make a config file for whatever reason
*
* @return void
* @author Dan Cox
*/
public function test_fail()
{
$this->setExpectedException('RuntimeException');
$this->fs->shouldReceive('mkdir')->with(WORKBENCH . 'test')->andThrow(new Exception());
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName(), 'name' => 'test']);
$this->assertContains('Failed', $CT->getDisplay());
}
示例4: __construct
/**
* Creates the Mockery based on the service name
*
* @param string $service
* @return void
* @author Dan Cox
*/
public function __construct($service)
{
$service = str_replace('.', '_', $service);
$this->mockery = \Mockery::mock($service);
// Add a call for the DI
$this->mockery->shouldReceive('getDI')->andReturn($this->mockery);
$this->mockery->shouldReceive('setDI')->andReturn($this->mockery);
}
示例5: test_invalidCron
/**
* Test when a cron cannot be found
*
* @return void
* @author Dan Cox
*/
public function test_invalidCron()
{
$this->setExpectedException('RuntimeException');
$this->database->shouldReceive('setModel')->with('Alice\\Entity\\Cron')->andReturn($this->database);
$this->database->shouldReceive('count')->andReturn(0);
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName(), 'name' => 'test']);
}
示例6: test_addFail
/**
* Test a fail case
*
* @return void
* @author Dan Cox
*/
public function test_addFail()
{
$this->database->shouldReceive('setModel')->with('Alice\\Entity\\Contact')->andReturn($this->database);
$this->database->shouldReceive('getEntity')->andThrow('Exception');
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName(), 'first' => 'test', 'last' => 'test', 'email' => 'test@test.com', '--phone' => '12345678910']);
$this->assertContains('There was an issue', $CT->getDisplay());
}
示例7: test_createFileFirst
/**
* Test Creating the file first
*
* @return void
* @author Dan Cox
*/
public function test_createFileFirst()
{
$this->fs->shouldReceive('exists')->andReturn(FALSE);
$this->config->shouldReceive('create')->andReturn($this->config);
$this->config->shouldReceive('params')->andReturn($this->config);
$this->config->shouldReceive('save');
$this->log->write('file.yml', 'logname', array('data' => array()));
}
示例8: test_createConfigurationFiles
/**
* Test creating config files for the mod
*
* @return void
* @author Dan Cox
*/
public function test_createConfigurationFiles()
{
$this->config->shouldReceive('create')->andReturn($this->config);
$this->config->shouldReceive('params')->andReturn($this->config);
$this->config->shouldReceive('save');
$tool = new ModuleTool();
$tool->config(['test' => 'value']);
$this->assertEquals('value', $this->config->test);
}
示例9: test_update
/**
* Basic test
*
* @return void
* @author Dan Cox
*/
public function test_update()
{
$this->cron->shouldReceive('updateFromDB');
$this->process->shouldReceive('build')->andReturn($this->process);
$this->process->shouldReceive('getProcess')->andReturn($this->process);
$this->process->shouldReceive('mustRun');
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName()]);
$this->assertContains('Updated', $CT->getDisplay());
}
示例10: test_runThroughFailDoctrine
/**
* Test a run through that fails on dctrine
*
* @return void
* @author Dan Cox
*/
public function test_runThroughFailDoctrine()
{
$this->DI->addMock('doctrineprocess', $this->doctrine);
$this->doctrine->shouldReceive('build')->with(['force' => true])->andReturn($this->doctrine);
$this->doctrine->shouldReceive('getProcess')->andReturn($this->doctrine);
$this->doctrine->shouldReceive('mustRun')->andThrow('Exception');
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName()]);
$this->assertContains('Failed updating schema...', $CT->getDisplay());
}
示例11: test_runThrough
/**
* Command is simple, lets just test a run through
*
* @return void
* @author Dan Cox
*/
public function test_runThrough()
{
$this->DI->addMock('config', $this->config);
$this->config->shouldReceive('create');
$this->config->shouldReceive('params')->andReturn($this->config);
$this->config->shouldReceive('save');
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName(), 'name' => 'test']);
$this->assertContains("Saved project file", $CT->getDisplay());
}
示例12: test_runThrough
/**
* Test a run through with a mocked process
*
* @return void
* @author Dan Cox
*/
public function test_runThrough()
{
$this->DI->addMock('doctrineprocess', $this->doctrine);
$this->doctrine->shouldReceive('build')->with(['force' => true])->andReturn($this->doctrine);
$this->doctrine->shouldReceive('getProcess')->andReturn($this->doctrine);
$this->doctrine->shouldReceive('run');
$this->doctrine->shouldReceive('isSuccessful')->andReturn(TRUE);
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName()]);
$this->assertContains('Successfully updated the database schema', $CT->getDisplay());
}
示例13: test_deactivate
/**
* Test deactivating a mod
*
* @return void
* @author Dan Cox
*/
public function test_deactivate()
{
$this->config->shouldReceive('load');
$this->probe->shouldReceive('load')->with('/var/www/');
$this->probe->shouldReceive('deactivateModule');
$this->config->shouldReceive('params')->andReturn($this->config);
$this->config->modules = array('mod' => '/var/www');
$mod = new Modules();
$mod->library()->availableModules = array('mod' => '/var/www/');
$mod->deactivate('mod');
}
示例14: test_updateCronTabText
/**
* Test updating crontab text file
*
* @return void
* @author Dan Cox
*/
public function test_updateCronTabText()
{
$this->database->shouldReceive('setModel')->with('Alice\\Entity\\Cron')->andReturn($this->database);
$this->database->shouldReceive('get')->andReturn([$this->database]);
// 1 Result.
$this->database->jobdate = '* * * * *';
$this->database->id = 1;
$this->fs->shouldReceive('dumpFile')->with('/tmp/crontab.txt', "* * * * * /usr/bin/php " . ROOT . "alice cron:run 1\n");
$cron = new Cron();
$cron->updateFromDB();
}
示例15: test_runThroughCommand
/**
* Test a working run through of the command
*
* @return void
* @author Dan Cox
*/
public function test_runThroughCommand()
{
$this->command->getHelper('question')->setInputStream($this->inputStream("git init, touch readme.md\nvalue = test, foo = bar\n"));
// Database expectations
$this->database->shouldReceive('getEntity')->andReturn($this->database);
$this->database->shouldReceive('persist');
$this->database->shouldReceive('flush');
// Mock the config class
$this->DI->addMock('config', $this->config);
$this->config->shouldReceive('create')->with(CONFIG . 'commands/test.command.yml');
$this->config->shouldReceive('params')->andReturn($this->config);
$this->config->shouldReceive('save');
$CT = new CommandTester($this->command);
$CT->execute(['command' => $this->command->getName(), 'name' => 'test.command']);
}