本文整理汇总了PHP中Codeception\Util\Stub::makeEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP Stub::makeEmpty方法的具体用法?PHP Stub::makeEmpty怎么用?PHP Stub::makeEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codeception\Util\Stub
的用法示例。
在下文中一共展示了Stub::makeEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例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: 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());
}
}
示例5: 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));
}
示例6: setUp
public function setUp()
{
$this->module = new \Codeception\Module\SOAP(make_container());
$this->module->_setConfig(array('schema' => 'http://www.w3.org/2001/xml.xsd', 'endpoint' => 'http://codeception.com/api/wsdl'));
$this->layout = \Codeception\Configuration::dataDir() . '/xml/layout.xml';
$this->module->isFunctional = true;
$this->module->_before(Stub::makeEmpty('\\Codeception\\Test\\Test'));
$this->module->client = Stub::makeEmpty('\\Codeception\\Lib\\Connector\\Universal');
}
示例7: setUp
public function setUp()
{
$this->module = new \Codeception\Module\REST();
$connector = new \Codeception\Util\Connector\Universal();
$connector->setIndex(\Codeception\Configuration::dataDir() . '/rest/index.php');
$this->module->client = $connector;
$this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest'));
$this->module->client->setServerParameters(array('SCRIPT_FILENAME' => 'index.php', 'SCRIPT_NAME' => 'index', 'SERVER_NAME' => 'localhost', 'SERVER_PROTOCOL' => 'http'));
}
示例8: testMakeEmptyMethodReplaced
public function testMakeEmptyMethodReplaced()
{
$dummy = Stub::makeEmpty('DummyClass', array('helloWorld' => function () {
return 'good bye world';
}));
$this->assertTrue(method_exists($dummy, 'helloWorld'));
$this->assertNotEquals($this->dummy->helloWorld(), $dummy->helloWorld());
$this->assertEquals($dummy->helloWorld(), 'good bye world');
}
示例9: setUp
public function setUp()
{
$this->dispatcher = new Symfony\Component\EventDispatcher\EventDispatcher();
$settings = \Codeception\Configuration::$defaultSuiteSettings;
$settings['class_name'] = 'CodeGuy';
$this->suiteman = new \Codeception\SuiteManager($this->dispatcher, 'suite', $settings);
$printer = \Codeception\Util\Stub::makeEmpty('PHPUnit_TextUI_ResultPrinter');
$this->runner = new \Codeception\PHPUnit\Runner();
$this->runner->setPrinter($printer);
}
示例10: testCheckingFreshnessOfCache
public function testCheckingFreshnessOfCache()
{
// Given...
$kernel = Stub::makeEmpty('Symfony\\Component\\HttpKernel\\KernelInterface', ['isDebug' => TRUE]);
$cache = new RamlDocSymfonyCache($kernel);
// When...
$isFresh = $cache->isFresh();
// Then...
$this->assertFalse($isFresh);
}
示例11: generateFilename
public function generateFilename(CodeGuy $I)
{
$I->haveFakeClass($stub = Stub::make($this->class, array('test' => Stub::makeEmpty('\\Codeception\\TestCase\\Cept', array('getFileName' => function () {
return 'testtest';
})))));
$I->executeTestedMethod($stub);
$I->seeResultEquals(\Codeception\Configuration::logDir() . 'debug' . DIRECTORY_SEPARATOR . 'testtest - 1');
$I->executeTestedMethod($stub, 'mytest');
$I->seeResultEquals(\Codeception\Configuration::logDir() . 'debug' . DIRECTORY_SEPARATOR . 'testtest - 2 - mytest');
}
示例12: setUp
public function setUp()
{
$this->module = new \Codeception\Module\Queue(make_container());
$this->module->_setConfig($this->config);
$this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase'));
try {
$this->module->clearQueue('default');
} catch (\Pheanstalk_Exception_ConnectionException $e) {
$this->markTestSkipped("Beanstalk is not running");
}
}
示例13: testBeforeHookResetsVariables
public function testBeforeHookResetsVariables()
{
$this->module->haveHttpHeader('Origin', 'http://www.example.com');
$this->module->sendGET('/rest/user/');
$server = $this->module->client->getInternalRequest()->getServer();
$this->assertArrayHasKey('HTTP_ORIGIN', $server);
$this->module->_before(Stub::makeEmpty('\\Codeception\\Test\\Test'));
$this->module->sendGET('/rest/user/');
$server = $this->module->client->getInternalRequest()->getServer();
$this->assertArrayNotHasKey('HTTP_ORIGIN', $server);
}
示例14: setUp
public function setUp()
{
$this->phpBrowser = new \Codeception\Module\PhpBrowser();
$url = 'http://localhost:8010';
$this->phpBrowser->_setConfig(array('url' => $url));
$this->phpBrowser->_initialize();
$this->module = Stub::make('\\Codeception\\Module\\REST', ['getModules' => [$this->phpBrowser]]);
$this->module->_initialize();
$this->module->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest'));
$this->phpBrowser->_before(Stub::makeEmpty('\\Codeception\\TestCase\\Cest'));
}
示例15: testFindingInlineBodySchema
/**
* @depends testNavigatingARaml
*/
public function testFindingInlineBodySchema()
{
/* Given... (Fixture) */
$jsonCoder = Stub::makeEmpty('GoIntegro\\Json\\JsonCoder');
$ramlDoc = Stub::makeEmpty('GoIntegro\\Raml\\RamlDoc', ['rawRaml' => Yaml::parse(__DIR__ . self::INLINE_BODY_SCHEMA_RAML), 'schemas' => Stub::makeEmpty('GoIntegro\\Raml\\Root\\MapCollection')]);
$navigator = new DocNavigator($ramlDoc, $jsonCoder);
/* When... (Action) */
$schema = $navigator->findRequestSchema(RamlSpec::HTTP_POST, '/some-resources');
/* Then... (Assertions) */
$this->assertEquals(self::INLINE_BODY_SCHEMA, $schema);
}