本文整理汇总了PHP中Codeception\Util\Stub类的典型用法代码示例。如果您正苦于以下问题:PHP Stub类的具体用法?PHP Stub怎么用?PHP Stub使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Stub类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:iwai,项目名称:elasticsearch-guzzle5connection,代码行数:7,代码来源:Guzzle5ConnectionTest.php
示例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);
}
开发者ID:BatVane,项目名称:Codeception,代码行数:7,代码来源:ScenarioCest.php
示例3: makeTest
protected function makeTest()
{
return Stub::makeEmpty(
'\Codeception\TestCase\Cept',
array('dispatcher' => Stub::makeEmpty('Symfony\Component\EventDispatcher\EventDispatcher'))
);
}
开发者ID:hendryguna,项目名称:laravel-basic,代码行数:7,代码来源:FacebookTest.php
示例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'));
}
开发者ID:pfz,项目名称:codeception,代码行数:7,代码来源:DbTest.php
示例5: makeTestCase
protected function makeTestCase($file, $name = '')
{
return Stub::make('\Codeception\Lib\DescriptiveTestCase', [
'getReportFields' => ['file' => codecept_root_dir() . $file],
'getName' => $name]
);
}
开发者ID:Vrian7ipx,项目名称:cascadadev,代码行数:7,代码来源:GroupManagerTest.php
示例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;
}
开发者ID:lepca,项目名称:AllediaFramework,代码行数:7,代码来源:ExtensionsGenericHelper.php
示例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);
}
开发者ID:solutionDrive,项目名称:Codeception,代码行数:31,代码来源:BaseCommandRunner.php
示例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');
}
开发者ID:zhikiri,项目名称:storage,代码行数:7,代码来源:StorageTest.php
示例9: create
/**
* @return Client
*/
private static function create()
{
/** @var Delivery $delivery */
$delivery = Stub::make('ArchiDelivery\\Delivery');
$client = new Client($delivery);
return $client;
}
开发者ID:stee1cat,项目名称:archi-delivery,代码行数:10,代码来源:ClientTest.php
示例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);
}
开发者ID:gointegro,项目名称:hateoas,代码行数:28,代码来源:ResourceLinksHydrantTest.php
示例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);
}
开发者ID:awesomemotive,项目名称:drip,代码行数:8,代码来源:DripTest.php
示例12: test_unserialize_real_serialized_object
public function test_unserialize_real_serialized_object()
{
$user = Stub::make('StdClass', array('username' => 'username', 'email' => '[email protected]'));
$so = new SerializedObject(serialize($user));
$result = $so->unserialize();
$this->assertEquals($result->username, 'username');
$this->assertEquals($result->email, '[email protected]');
}
开发者ID:tequilarapido,项目名称:php-serialized,代码行数:8,代码来源:SerializedObjectTest.php
示例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');
}
开发者ID:careck,项目名称:bendms,代码行数:8,代码来源:ConfigTest-Copy.php
示例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));
}
开发者ID:Vlsirko,项目名称:yii2-uploads,代码行数:8,代码来源:UploadedFileTest.php
示例15: testHaveAndSeeInDatabase
public function testHaveAndSeeInDatabase()
{
$user_id = $this->module->haveInDatabase('users', array('name' => 'john', 'email' => '[email protected]'));
$this->assertInternalType('integer', $user_id);
$this->module->seeInDatabase('users', array('name' => 'john', 'email' => '[email protected]'));
$this->module->_after(\Codeception\Util\Stub::make('\Codeception\TestCase'));
$this->module->dontSeeInDatabase('users', array('name' => 'john'));
}
开发者ID:hendryguna,项目名称:laravel-basic,代码行数:8,代码来源:DbTest.php
示例16: testIsCloudflareRequest
public function testIsCloudflareRequest()
{
$tests = [[Stub::makeEmpty(RequestAdapter::class, ['getRemoteAddr' => '103.21.244.2', 'getHeaders' => ['cf-connecting-ip' => '127.0.0.1']]), true], [Stub::makeEmpty(RequestAdapter::class, ['getRemoteAddr' => '103.22.200.1', 'getHeaders' => ['cf-connecting-ip' => '127.0.0.1']]), true], [Stub::makeEmpty(RequestAdapter::class, ['getRemoteAddr' => '103.21.243.2', 'getHeaders' => ['cf-connecting-ip' => '127.0.0.1']]), false], [Stub::makeEmpty(RequestAdapter::class, ['getRemoteAddr' => '103.21.244.2', 'getHeaders' => ['custom-ip' => '127.0.0.1']]), false]];
foreach ($tests as $testData) {
list($request, $result) = $testData;
$this->assertEquals($result, (new CloudflareDetector($this->ipAddresses, $request))->isCloudflareRequest());
}
}
开发者ID:foowie,项目名称:cloudflare-detection,代码行数:8,代码来源:CloudflareDetectorTest.php
示例17: convertWithException
public function convertWithException(\CodeGuy $I)
{
$I->wantTo("test if converting of different measure types fails.");
$I->haveStub($converter = Stub::make($this->class));
$I->amTestingMethod('\\Measure\\Converter.convert');
$I->executeTestedMethodOn($converter, 1, 'liter', 'kg');
$I->seeExceptionThrown('\\ErrorException');
}
开发者ID:xobb,项目名称:mconv,代码行数:8,代码来源:ConverterCest.php
示例18: testGetDocumentsIdsReturnsEmptyArray
public function testGetDocumentsIdsReturnsEmptyArray()
{
$query = Stub::make(SearchQuery::class, ['getFilters' => function () {
return [];
}]);
$this->object = new ResultSet($query, []);
$this->assertSame([], $this->object->getDocumentIds());
}
开发者ID:scorpioframework,项目名称:sphinx-search,代码行数:8,代码来源:ResultSetTest.php
示例19: testBeforeHookResetsVariables
public function testBeforeHookResetsVariables()
{
$this->module->haveHttpHeader('Origin', 'http://www.example.com');
$this->module->sendGET('/rest/user/');
$this->assertEquals('http://www.example.com', $this->module->client->getServerParameter('HTTP_ORIGIN'));
$this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest'));
$this->assertNull($this->module->client->getServerParameter('HTTP_ORIGIN', null));
}
开发者ID:corcre,项目名称:elabftw,代码行数:8,代码来源:RestTest.php
示例20: testAddCestWithEnv
/**
* When running multiple environments, getClassesFromFile() method in SuiteManager is called once for each env.
* See \Codeception\Codecept::runSuite() - for each env new SuiteManager is created and tests loaded.
* Make sure that calling getClassesFromFile() multiple times will always return the same classes.
*
* @group core
*/
public function testAddCestWithEnv()
{
$file = \Codeception\Configuration::dataDir() . 'SimpleCestWithNamespace.php';
$this->suiteman->addCest($file);
$this->assertEquals(3, $this->suiteman->getSuite()->count());
$newSuiteMan = Stub::make('\\Codeception\\SuiteManager', array('dispatcher' => $this->dispatcher, 'suite' => new PHPUnit_Framework_TestSuite(), 'settings' => array('bootstrap' => false, 'class_name' => 'CodeGuy', 'namespace' => '')));
$newSuiteMan->addCest($file);
$this->assertEquals(3, $newSuiteMan->getSuite()->count());
}
开发者ID:lenninsanchez,项目名称:donadores,代码行数:16,代码来源:SuiteManagerTest.php
注:本文中的Codeception\Util\Stub类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论