本文整理汇总了PHP中Codeception\Util\Stub类的典型用法代码示例。如果您正苦于以下问题:PHP Stub类的具体用法?PHP Stub怎么用?PHP Stub使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Stub类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateInstanceWithRingPHP
public function testCreateInstanceWithRingPHP()
{
$log = $trace = Stub::make('\\Monolog\\Logger', []);
$ringphp_handler = Stub::make('WyriHaximus\\React\\RingPHP\\HttpClientAdapter');
$connection = new Guzzle5Connection(['host' => 'localhost', 'port' => 9200, 'ringphp_handler' => $ringphp_handler], null, $log, $trace);
$this->assertInstanceOf('Iwai\\Elasticsearch\\Guzzle5Connection', $connection);
}
示例2: run
public function run(CodeGuy $I)
{
$I->wantTo('run steps from scenario');
$I->haveStub($test = Stub::makeEmpty('\\Codeception\\TestCase\\Cept'));
$I->haveStub($scenario = Stub::make('\\Codeception\\Scenario', array('test' => $test, 'steps' => Stub::factory('\\Codeception\\Step', 2))));
$I->executeTestedMethodOn($scenario)->seeMethodInvoked($test, 'runStep')->seePropertyEquals($scenario, 'currentStep', 1);
}
示例3: makeTest
protected function makeTest()
{
return Stub::makeEmpty(
'\Codeception\TestCase\Cept',
array('dispatcher' => Stub::makeEmpty('Symfony\Component\EventDispatcher\EventDispatcher'))
);
}
示例4: testHaveAndSeeInDatabase
public function testHaveAndSeeInDatabase()
{
$this->module->haveInDatabase('users', array('name' => 'john'));
$this->module->seeInDatabase('users', array('name' => 'john'));
$this->module->_before(\Codeception\Util\Stub::make('\\Codeception\\TestCase'));
$this->module->dontSeeInDatabase('users', array('name' => 'john'));
}
示例5: makeTestCase
protected function makeTestCase($file, $name = '')
{
return Stub::make('\Codeception\Lib\DescriptiveTestCase', [
'getReportFields' => ['file' => codecept_root_dir() . $file],
'getName' => $name]
);
}
示例6: constructDumbGenericCLI
public function constructDumbGenericCLI($params = array(), $override = array())
{
$defaultParams = array('namespace' => 'DumbExtension', 'type' => 'cli');
$defaultOverride = array();
$instance = Stub::construct('\\Alledia\\Framework\\Joomla\\Extension\\Generic', array_merge($defaultParams, $params), array_merge($defaultOverride, $override));
return $instance;
}
示例7: makeCommand
protected function makeCommand($className, $saved = true, $extraMethods = [])
{
if (!$this->config) {
$this->config = [];
}
$self = $this;
$mockedMethods = ['save' => function ($file, $output) use($self, $saved) {
if (!$saved) {
return false;
}
$self->filename = $file;
$self->content = $output;
$self->log[] = ['filename' => $file, 'content' => $output];
$self->saved[$file] = $output;
return true;
}, 'getGlobalConfig' => function () use($self) {
return $self->config;
}, 'getSuiteConfig' => function () use($self) {
return $self->config;
}, 'buildPath' => function ($path, $testName) {
$path = rtrim($path, DIRECTORY_SEPARATOR);
$testName = str_replace(['/', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $testName);
return pathinfo($path . DIRECTORY_SEPARATOR . $testName, PATHINFO_DIRNAME) . DIRECTORY_SEPARATOR;
}, 'getSuites' => function () {
return ['shire'];
}, 'getApplication' => function () {
return new \Codeception\Util\Maybe();
}];
$mockedMethods = array_merge($mockedMethods, $extraMethods);
$this->command = Stub::construct($className, [$this->commandName], $mockedMethods);
}
示例8: testDispatchMethod
public function testDispatchMethod()
{
$separator = Storage::$separator;
$method = self::getPrivateMethod('dispatch');
$structure = $method->invoke(Stub::make(self::$class), "base{$separator}inner{$separator}key");
$this->assertEquals($structure, array('base', 'inner', 'key'), 'Parsing of the passed path is failed');
}
示例9: create
/**
* @return Client
*/
private static function create()
{
/** @var Delivery $delivery */
$delivery = Stub::make('ArchiDelivery\\Delivery');
$client = new Client($delivery);
return $client;
}
示例10: testParsingASimpleRequest
public function testParsingASimpleRequest()
{
// Given...
$repository = Stub::makeEmpty('Doctrine\\ORM\\EntityRepository', ['__call' => function ($name) {
switch ($name) {
case 'findOneById':
return self::AUTHOR_ENTITY;
break;
case 'findById':
return self::COMMENT_ENTITIES;
break;
}
}]);
$authorRelationship = Stub::makeEmpty('GoIntegro\\Hateoas\\Metadata\\Resource\\ResourceRelationship');
$commentsRelationship = Stub::makeEmpty('GoIntegro\\Hateoas\\Metadata\\Resource\\ResourceRelationship');
$relationships = Stub::makeEmpty('GoIntegro\\Hateoas\\Metadata\\Resource\\ResourceRelationships', ['toOne' => ['author' => $authorRelationship], 'toMany' => ['comments' => $commentsRelationship]]);
$metadata = Stub::makeEmpty('GoIntegro\\Hateoas\\Metadata\\Resource\\ResourceMetadata', ['relationships' => $relationships, 'isToOneRelationship' => TRUE, 'isToManyRelationship' => TRUE]);
$em = Stub::makeEmpty('Doctrine\\ORM\\EntityManagerInterface', ['getRepository' => $repository]);
$mm = Stub::makeEmpty('GoIntegro\\Hateoas\\Metadata\\Resource\\MetadataMinerInterface', ['mine' => $metadata]);
$hydrant = new ResourceLinksHydrant($em, $mm);
$params = Stub::makeEmpty('GoIntegro\\Hateoas\\JsonApi\\Request\\Params', ['primaryClass' => "HateoasInc\\Bundle\\ExampleBundle\\Entity\\User"]);
$resourceObject = ['content' => "Meh.", 'links' => ['author' => '5', 'comments' => ['45', '54', '67']]];
// When...
$hydrant->hydrate($params, $resourceObject);
$expected = ['content' => "Meh.", 'links' => ['author' => self::AUTHOR_ENTITY, 'comments' => self::COMMENT_ENTITIES]];
// Then...
$this->assertEquals($expected, $resourceObject);
}
示例11: testGetHttpClient
public function testGetHttpClient()
{
/** @var \AwesomeMotive\Drip\Token $token */
$token = Stub::make("\\AwesomeMotive\\Drip\\Token", ['get_accessToken' => '1234']);
$this->drip->set_token($token);
$client = $this->drip->get_httpClient();
$this->assertInstanceOf("\\GuzzleHttp\\Client", $client);
}
示例12: test_unserialize_real_serialized_object
public function test_unserialize_real_serialized_object()
{
$user = Stub::make('StdClass', array('username' => 'username', 'email' => 'email@example.com'));
$so = new SerializedObject(serialize($user));
$result = $so->unserialize();
$this->assertEquals($result->username, 'username');
$this->assertEquals($result->email, 'email@example.com');
}
示例13: _before
public function _before()
{
//echo "ENV:".getenv('thisTestRun_testIncludePath');
//die();
//chdir(getenv('thisTestRun_testIncludePath'));
//require_once "system/classes/Config.php";
$this->config = Stub::construct('Config');
}
示例14: testDelete
public function testDelete()
{
$file = Stub::construct('\\Uploads\\models\\UploadedFile', ['filePath' => $this->baseTestFileString], ['getOwnerClass' => 'Test', 'getOwnerId' => 2, 'getDirToUpload' => yii::getAlias(implode(DIRECTORY_SEPARATOR, ['@backend', 'web', 'upload']))]);
$file->save();
$filePath = $file->fullPath;
$file->delete();
$this->assertFalse(file_exists($filePath));
}
示例15: testHaveAndSeeInDatabase
public function testHaveAndSeeInDatabase()
{
$user_id = $this->module->haveInDatabase('users', array('name' => 'john', 'email' => 'john@jon.com'));
$this->assertInternalType('integer', $user_id);
$this->module->seeInDatabase('users', array('name' => 'john', 'email' => 'john@jon.com'));
$this->module->_after(\Codeception\Util\Stub::make('\Codeception\TestCase'));
$this->module->dontSeeInDatabase('users', array('name' => 'john'));
}