本文整理汇总了PHP中AspectMock\Test类的典型用法代码示例。如果您正苦于以下问题:PHP Test类的具体用法?PHP Test怎么用?PHP Test使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanSetSail
public function testCanSetSail()
{
$config = array('routes' => array('/' => array('controller' => 'index', 'action' => 'index', 'params' => array())));
Test::double('\\Bone\\Mvc\\Request', ['getURI' => '/']);
Test::double('\\Bone\\Mvc\\Dispatcher', ['fireCannons' => null]);
$this->assertNull(Application::ahoy($config)->setSail());
}
示例2: tearDown
public function tearDown()
{
parent::tearDown();
Mockery::close();
Test::clean();
$this->dropDatabase();
}
示例3: testStop
/**
* Test shutting down the bitcoin server
* Fake client so it doesnt really shut down
*/
public function testStop()
{
Test::double('Del\\Bitcoin\\Api\\AbstractApi', ['send' => null]);
$this->api = new Control($this->config);
$result = $this->api->stop();
$this->assertNull($result);
}
示例4: testBehatCommand
public function testBehatCommand()
{
$behat = test::double('Robo\\Task\\Testing\\Behat', ['executeCommand' => null, 'getConfig' => new \Robo\Config(), 'logger' => new \Psr\Log\NullLogger()]);
$task = (new \Robo\Task\Testing\Behat('behat'))->stopOnFail()->noInteraction()->colors();
verify($task->getCommand())->equals('behat run --stop-on-failure --no-interaction --colors');
$task->run();
$behat->verifyInvoked('executeCommand', ['behat run --stop-on-failure --no-interaction --colors']);
}
示例5: testUnsuccessfulUnsubscribe
/**
* @expectedException \Boedy\Subscription\SubscriptionErrorException
*/
public function testUnsuccessfulUnsubscribe()
{
$parameters = array('client_id' => '123456789', 'client_secret' => 'abcdefghij');
//return 400 response
Test::double('\\Boedy\\Http\\Request\\Delete', ['exec' => new HttpResponse('header', 'body', 400)]);
$factory = new HttpRequestFactory();
$instagramAdapter = new InstagramAdapter($factory);
$instagramAdapter->unsubscribe($parameters);
}
示例6: testCreateController
public function testCreateController()
{
Test::double('\\Twig_Loader_Filesystem');
Test::double('\\Twig_Environment');
Test::double('\\Twig_Extension_Debug');
Test::double('\\Bone\\Mvc\\Controller', array('setTwig' => null));
$factory = new ControllerFactory();
$controller = $factory->create('\\Bone\\Mvc\\Controller', $this->request);
$this->assertInstanceOf('\\Bone\\Mvc\\Controller', $controller);
}
示例7: testUpdateListHasNothingToUpdate
public function testUpdateListHasNothingToUpdate()
{
$userStubs = [['id' => 1], ['id' => 2]];
$localCollectionStub = Test::double('PullAutomaticallyGalleries\\Database\\Eloquent\\Collection', ['diffByKey' => &$localCollectionStub, 'isEmpty' => true])->make();
$remoteCollectionStub = Test::double('PullAutomaticallyGalleries\\Support\\Collection', ['diffByKey' => &$remoteCollectionStub, 'isEmpty' => true])->make();
Gallery::shouldReceive('getByUsers')->with([1, 2])->once()->andReturn($localCollectionStub)->getMock();
RemoteGallery::shouldReceive('getByUsers')->with($userStubs)->once()->andReturn($remoteCollectionStub);
$this->call('POST', 'galleries', ['users' => $userStubs]);
$this->assertRedirectedTo('users');
$this->assertSessionHas('message', 'Has been removed 0 galleries and created 0 galleries');
}
示例8: testConnectionStatusIsUpdatedWithFailureAfterConfigSave
public function testConnectionStatusIsUpdatedWithFailureAfterConfigSave()
{
AspectMock\Test::double("Tinify\\Client", ["request" => function () {
throw new Tinify\AccountException("help an error");
}]);
$this->configModel->setDataByPath(Model\Config::KEY_PATH, "my_new_key");
$this->configModel->save();
$label = $this->getObjectManager()->get("Magento\\Framework\\Data\\Form\\Element\\Label");
$status = $this->getObjectManager()->get("Tinify\\Magento\\Model\\Config\\ConnectionStatusField");
$this->assertEquals('<td class="value">' . '<div class="tinify-connection-status tinify-failure">' . '<div class="control-value">API connection unsuccessful.</div>' . '</div>' . '<p class="note"><span>Error: help an error</span></p>' . '</td>', $this->callMethod($status, "_renderValue", $label));
}
示例9: testMockingClassMethod
public function testMockingClassMethod()
{
$this->initAspectMock();
//$mock = \AspectMock\Test::double(MyClass::class, ['myClassMethod' => 'a']);
$mock = \AspectMock\Test::double('MyClass', ['myClassMethod' => 'a']);
//$mock = \AspectMock\Test::double('\MyClass', ['myClassMethod' => 'a']);
$classMethodReturned = MyClass::myClassMethod();
// Extra verification to see if the AspectMock double is actually being run yet:
//$mock->verifyInvoked('myClassMethod');
$this->assertEquals('a', $classMethodReturned);
}
示例10: _after
public function _after(\Codeception\TestCase $test)
{
// Ensure that $stopOnFail global static is reset, as tests
// that set it to true will force an exception, and therefor
// will not have a chance to clean this up.
\Robo\Result::$stopOnFail = false;
\AspectMock\Test::clean();
$consoleOutput = new ConsoleOutput();
static::$container->add('output', $consoleOutput);
static::$container->add('logger', new \Consolidation\Log\Logger($consoleOutput));
}
示例11: testSemver
public function testSemver()
{
$semver = test::double('Robo\\Task\\SemVerTask', ['dump' => null]);
$res = $this->taskSemVer()->increment('major')->prerelease('RC')->increment('patch')->run();
verify($res->getMessage())->equals('v1.0.1-RC.1');
$semver->verifyInvoked('dump');
}
示例12: it_should_fire_job_with_resolvable_models
/**
* @test
*/
public function it_should_fire_job_with_resolvable_models()
{
/**
*
* Set
*
*/
$app = m::mock('Illuminate\\Foundation\\Application');
$config = m::mock('Menthol\\Flexible\\Config');
$logger = m::mock('Monolog\\Logger');
$model = m::mock('Husband');
$model->shouldReceive('refreshDoc')->with($model)->once();
$husband = am::double('Husband', ['findOrFail' => $model]);
$models = ['Husband:999'];
/**
*
* Expectation
*
*/
$logger->shouldReceive('info')->with('Indexing Husband with ID: 999');
$config->shouldReceive('get')->with('logger', 'menthol.flexible.logger')->andReturn('menthol.flexible.logger');
$app->shouldReceive('make')->with('menthol.flexible.logger')->andReturn($logger);
$job = m::mock('Illuminate\\Queue\\Jobs\\Job');
$job->shouldReceive('delete')->once();
/**
*
* Assertion
*
*/
with(new ReindexJob($app, $config))->fire($job, $models);
// $husband->verifyInvoked('findOrFail');
}
示例13: testModelCall
public function testModelCall()
{
// This test demonstrates how to create a test double for Mage
// Normally you would be testing a separate classes method so
// some of the logic below would be in a separate file, obvs.
// Using PhpUnits mock builder we can create a stub object for
// a Magento core file. Which allows us to control what the
// method calls return and also assert they are invoked, etc.
$mockModel = $this->getMockBuilder('Mage_Catalog_Model_Product')->setMethods(array('getSku'))->getMock();
$mockModel->expects($this->once())->method('getSku')->will($this->returnValue('123456789'));
// Because getting a model in Magento consists of a static call
// it makes testing difficult. To counter this we are using a
// library called AspectMock which uses Go! AOP to allow us to
// create test doubles for static method calls. WIN!
$modelStub = test::double('Mage', ['getModel' => $mockModel]);
// This is the logic we would be testing
$model = Mage::getModel('catalog/product');
$sku = $model->getSku();
// Because our $modelStub returned our $mockModel when Mage::getModel()
// is called $model is the same as our $mockModel. By calling getSku()
// we are using the stubbed model method which returns our defined result.
$this->assertSame('123456789', $sku);
// We will also want to assert that the stubbed static method was
// actually called.
$modelStub->verifyInvokedOnce('getModel', 'catalog/product');
}
示例14: _before
protected function _before()
{
$progressBar = test::double('Symfony\\Component\\Console\\Helper\\ProgressBar');
$nullOutput = new \Symfony\Component\Console\Output\NullOutput();
$progressIndicator = new \Robo\Common\ProgressIndicator($progressBar, $nullOutput);
$this->svn = test::double('Robo\\Task\\Vcs\\SvnStack', ['executeCommand' => new \AspectMock\Proxy\Anything(), 'output' => $nullOutput, 'logger' => new \Psr\Log\NullLogger(), 'logger' => Robo::logger(), 'getConfig' => Robo::config(), 'progressIndicator' => $progressIndicator]);
}
示例15: it_should_fire_job_with_resolvable_models
/**
* @test
*/
public function it_should_fire_job_with_resolvable_models()
{
/**
*
* Set
*
*/
$model = m::mock('Husband');
$model->shouldReceive('refreshDoc')->with($model)->once();
$husband = am::double('Husband', ['findOrFail' => $model]);
$models = ['Husband:999'];
/**
*
* Expectation
*
*/
$job = m::mock('Illuminate\\Queue\\Jobs\\Job');
$job->shouldReceive('delete')->once();
/**
*
* Assertion
*
*/
with(new ReindexJob())->fire($job, $models);
$husband->verifyInvoked('findOrFail');
}