当前位置: 首页>>代码示例>>PHP>>正文


PHP Mockery::getConfiguration方法代码示例

本文整理汇总了PHP中Mockery::getConfiguration方法的典型用法代码示例。如果您正苦于以下问题:PHP Mockery::getConfiguration方法的具体用法?PHP Mockery::getConfiguration怎么用?PHP Mockery::getConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mockery的用法示例。


在下文中一共展示了Mockery::getConfiguration方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testValidate

 /**
  * @dataProvider validateProvider
  */
 public function testValidate($path, $isExceptionExpected, $isUserInDatabase, $isFull, $codeExists)
 {
     $ds = DIRECTORY_SEPARATOR;
     $data = Yaml::parse(file_get_contents($path . $ds . 'manifest.yml'));
     $properties['properties'] = $data['properties'];
     if ($isExceptionExpected) {
         $this->setExpectedException('Exception');
     }
     m::getConfiguration()->allowMockingNonExistentMethods(true);
     //init importer
     $this->importer->setRootPath($path);
     $resolver = new Resolver($path);
     $this->importer->setConfiguration($resolver->resolve($data));
     //objectManager
     $wsRepo = $this->mock('Claroline\\CoreBundle\\Repository\\WorkspaceRepository');
     $this->om->shouldReceive('getRepository')->with('Claroline\\CoreBundle\\Entity\\Workspace\\Workspace')->andReturn($wsRepo);
     if ($codeExists) {
         $wsRepo->shouldReceive('findOneByCode')->once()->with($properties['properties']['code'])->andThrow('Exception');
     } else {
         $wsRepo->shouldReceive('findOneByCode')->once()->with($properties['properties']['code'])->andReturn('ws');
     }
     $userRepo = $this->mock('Claroline\\CoreBundle\\Repository\\UserRepository');
     if ($isUserInDatabase && !$isFull) {
         $this->om->shouldReceive('getRepository')->andReturn($userRepo);
         $userRepo->shouldReceive('findOneByUsername')->andReturn('user');
     }
     if (!$isUserInDatabase && !$isFull) {
         $this->om->shouldReceive('getRepository')->andReturn($userRepo);
         $userRepo->shouldReceive('findOneByUsername')->andThrow('Exception');
     }
     $this->importer->validate($properties);
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:35,代码来源:WorkspacePropertiesImporterTest.php

示例2: setUp

 public function setUp()
 {
     \Mockery::getConfiguration()->setInternalClassMethodParamMap('MongoCollection', 'save', array('&$data', '$options = array()'));
     $this->collection = \Mockery::mock('MongoCollection');
     $this->collection->shouldReceive('ensureIndex');
     $this->db = \Mockery::mock('MongoDB');
     $this->db->shouldReceive('selectCollection')->andReturn($this->collection);
     Moa::setup($this->db);
 }
开发者ID:99designs,项目名称:moa,代码行数:9,代码来源:DomainObjectTest.php

示例3: testAnonymousMockWorksWithNotAllowingMockingOfNonExistantMethods

 public function testAnonymousMockWorksWithNotAllowingMockingOfNonExistantMethods()
 {
     $before = \Mockery::getConfiguration()->mockingNonExistentMethodsAllowed();
     \Mockery::getConfiguration()->allowMockingNonExistentMethods(false);
     $m = $this->container->mock();
     $m->shouldReceive("test123")->andReturn(true);
     assertThat($m->test123(), equalTo(true));
     \Mockery::getConfiguration()->allowMockingNonExistentMethods(true);
 }
开发者ID:deepakb,项目名称:test-driven-development-example,代码行数:9,代码来源:MockTest.php

示例4: assertThat

 public function testMockWithNotAllowingMockingOfNonExistentMethodsCanBeGivenAdditionalMethodsToMockEvenIfTheyDontExistOnClass()
 {
     \Mockery::getConfiguration()->allowMockingNonExistentMethods(false);
     $m = $this->container->mock('ExampleClassForTestingNonExistentMethod');
     $m->shouldAllowMockingMethod('testSomeNonExistentMethod');
     $m->shouldReceive("testSomeNonExistentMethod")->andReturn(true);
     assertThat($m->testSomeNonExistentMethod(), equalTo(true));
     \Mockery::getConfiguration()->allowMockingNonExistentMethods(true);
 }
开发者ID:dileepxervmon,项目名称:Xdocker,代码行数:9,代码来源:MockTest.php

示例5: testSearchIcon

 /**
  * @group resource
  */
 public function testSearchIcon()
 {
     $icon = new \Claroline\CoreBundle\Entity\Resource\ResourceIcon();
     $mimeType = 'video/mp4';
     m::getConfiguration()->allowMockingNonExistentMethods(true);
     $this->repo->shouldReceive('findOneByMimeType')->with($mimeType)->once()->andReturn(null);
     $this->repo->shouldReceive('findOneByMimeType')->with('video')->once()->andReturn(null);
     $this->repo->shouldReceive('findOneByMimeType')->with('custom/default')->once()->andReturn($icon);
     $this->assertEquals($icon, $this->getManager()->searchIcon($mimeType));
 }
开发者ID:ngydat,项目名称:CoreBundle,代码行数:13,代码来源:IconManagerTest.php

示例6: testSave

 public function testSave()
 {
     \Mockery::getConfiguration()->setInternalClassMethodParamMap('MongoCollection', 'save', array('&$data', '$options = array()'));
     $collection = Mockery::mock('MongoCollection')->shouldReceive('save')->with(array('key' => 'value'), array())->andReturnUsing(function (&$mongoDoc) {
         $mongoDoc['_id'] = 100;
     })->mock();
     $wrappedCollection = new Moa\DomainObject\Finder($collection, 'MyModel');
     $model = new MyModel(array('key' => 'value'));
     $wrappedCollection->save($model);
     $this->assertEquals(100, $model->id());
 }
开发者ID:99designs,项目名称:moa,代码行数:11,代码来源:FinderTest.php

示例7: Setup

 function Setup()
 {
     \Mockery::getConfiguration()->allowMockingNonExistentMethods(true);
     $this->resolver = new \Zend\View\Resolver\TemplatePathStack();
     foreach ((array) $this->getTemplatePaths() as $path) {
         $this->resolver->addPath($path);
     }
     $this->renderer = $this->createRenderer();
     $this->renderer->setResolver($this->resolver);
     $this->setFormHelpers();
 }
开发者ID:noikiy,项目名称:tools,代码行数:11,代码来源:RenderableTestCase.php

示例8: testCanOverrideExpectedParametersOfInternalPHPClassesToPreserveRefs

 public function testCanOverrideExpectedParametersOfInternalPHPClassesToPreserveRefs()
 {
     if (!class_exists('MongoCollection', false)) {
         $this->markTestSkipped('ext/mongo not installed');
     }
     \Mockery::getConfiguration()->setInternalClassMethodParamMap('MongoCollection', 'insert', array('&$data', '$options'));
     $m = $this->container->mock('MongoCollection');
     $m->shouldReceive('insert')->with(\Mockery::on(function (&$data) {
         $data['_id'] = 123;
         return true;
     }), \Mockery::type('array'));
     $data = array('a' => 1, 'b' => 2);
     $m->insert($data, array());
     $this->assertTrue(isset($data['_id']));
     $this->assertEquals(123, $data['_id']);
     $this->container->mockery_verify();
     \Mockery::resetContainer();
 }
开发者ID:deepakb,项目名称:test-driven-development-example,代码行数:18,代码来源:ContainerTest.php

示例9: testImportUsersIntoGroupAction

 public function testImportUsersIntoGroupAction()
 {
     vfsStream::setup('root', null, array('users.txt' => "gg,gg,gg,gg,gg,gg,gg"));
     $group = $this->mock('Claroline\\CoreBundle\\Entity\\Group');
     $group->shouldReceive('getId')->andReturn(42);
     $form = $this->mock('Symfony\\Component\\Form\\Form');
     $this->formFactory->shouldReceive('create')->with(FormFactory::TYPE_USER_IMPORT)->once()->andReturn($form);
     $form->shouldReceive('handleRequest')->with($this->request)->once();
     $form->shouldReceive('isValid')->with()->once()->andReturn(true);
     m::getConfiguration()->allowMockingNonExistentMethods(true);
     $form->shouldReceive('get->getData')->andReturn(vfsStream::url('root/users.txt'));
     m::getConfiguration()->allowMockingNonExistentMethods(false);
     $users = array(array('gg', 'gg', 'gg', 'gg', 'gg', 'gg', 'gg'));
     $this->userManager->shouldReceive('importUsers')->once()->with($users);
     $this->groupManager->shouldReceive('importUsers')->once()->with($group, $users);
     $this->router->shouldReceive('generate')->once()->with('claro_admin_user_of_group_list', array('groupId' => 42))->andReturn('azertyuiop');
     $this->assertTrue($this->getController()->importUsersIntoGroupAction($group) instanceof RedirectResponse);
 }
开发者ID:ChMat,项目名称:CoreBundle,代码行数:18,代码来源:AdministrationControllerTest.php

示例10: _mockery_handleMethodCall

 protected function _mockery_handleMethodCall($method, array $args)
 {
     $this->_mockery_getReceivedMethodCalls()->push(new \Mockery\MethodCall($method, $args));
     $rm = $this->mockery_getMethod($method);
     if ($rm && $rm->isProtected() && !$this->_mockery_allowMockingProtectedMethods) {
         if ($rm->isAbstract()) {
             return;
         }
         try {
             $prototype = $rm->getPrototype();
             if ($prototype->isAbstract()) {
                 return;
             }
         } catch (\ReflectionException $re) {
             // noop - there is no hasPrototype method
         }
         return call_user_func_array("parent::{$method}", $args);
     }
     if (isset($this->_mockery_expectations[$method]) && !$this->_mockery_disableExpectationMatching) {
         $handler = $this->_mockery_expectations[$method];
         try {
             return $handler->call($args);
         } catch (\Mockery\Exception\NoMatchingExpectationException $e) {
             if (!$this->_mockery_ignoreMissing && !$this->_mockery_deferMissing) {
                 throw $e;
             }
         }
     }
     if (!is_null($this->_mockery_partial) && method_exists($this->_mockery_partial, $method)) {
         return call_user_func_array(array($this->_mockery_partial, $method), $args);
     } elseif ($this->_mockery_deferMissing && is_callable("parent::{$method}")) {
         return call_user_func_array("parent::{$method}", $args);
     } elseif ($method == '__toString') {
         // __toString is special because we force its addition to the class API regardless of the
         // original implementation.  Thus, we should always return a string rather than honor
         // _mockery_ignoreMissing and break the API with an error.
         return sprintf("%s#%s", __CLASS__, spl_object_hash($this));
     } elseif ($this->_mockery_ignoreMissing) {
         if (\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() || (method_exists($this->_mockery_partial, $method) || is_callable("parent::{$method}"))) {
             if ($this->_mockery_defaultReturnValue instanceof \Mockery\Undefined) {
                 return call_user_func_array(array($this->_mockery_defaultReturnValue, $method), $args);
             } elseif (null === $this->_mockery_defaultReturnValue) {
                 return $this->mockery_returnValueForMethod($method);
             } else {
                 return $this->_mockery_defaultReturnValue;
             }
         }
     }
     $message = 'Method ' . __CLASS__ . '::' . $method . '() does not exist on this mock object';
     if (!is_null($rm)) {
         $message = 'Received ' . __CLASS__ . '::' . $method . '(), but no expectations were specified';
     }
     throw new \BadMethodCallException($message);
 }
开发者ID:quizlet,项目名称:mockery,代码行数:54,代码来源:Mock.php

示例11: tearDown

 public function tearDown()
 {
     \Mockery::getConfiguration()->allowMockingNonExistentMethods(true);
     $this->container->mockery_close();
 }
开发者ID:no-chris,项目名称:connector,代码行数:5,代码来源:HamcrestExpectationTest.php

示例12: dirname

<?php

$autoloader = (require_once dirname(__DIR__) . '/vendor/autoload.php');
$autoloader->add('Swift_', __DIR__ . '/unit');
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__DIR__) . '/lib');
\Mockery::getConfiguration()->allowMockingNonExistentMethods(false);
if (is_file(__DIR__ . '/acceptance.conf.php')) {
    require_once __DIR__ . '/acceptance.conf.php';
}
if (is_file(__DIR__ . '/smoke.conf.php')) {
    require_once __DIR__ . '/smoke.conf.php';
}
require_once __DIR__ . '/StreamCollector.php';
require_once __DIR__ . '/IdenticalBinaryConstraint.php';
require_once __DIR__ . '/SwiftMailerTestCase.php';
require_once __DIR__ . '/SwiftMailerSmokeTestCase.php';
开发者ID:EnmanuelCode,项目名称:backend-laravel,代码行数:16,代码来源:bootstrap.php

示例13: allowMockingNonExistentMethods

 /**
  * Call allowMockingNonExistentMethods() on setUp().
  *
  * @param bool $allow Enable/Disable to mock non existent methods.
  */
 public function allowMockingNonExistentMethods($allow = false)
 {
     //Disable mocking of non existent methods.
     $config = Mock::getConfiguration();
     $config->allowMockingNonExistentMethods($allow);
 }
开发者ID:narrowspark,项目名称:testing-helper,代码行数:11,代码来源:MockeryTrait.php

示例14: setUp

 protected function setUp()
 {
     m::getConfiguration()->allowMockingNonExistentMethods(false);
     m::getConfiguration()->allowMockingMethodsUnnecessarily(false);
 }
开发者ID:tisseo-deploy,项目名称:MigrationBundle,代码行数:5,代码来源:MockeryTestCase.php

示例15: testWetherMockWithInterfaceOnlyCanNotImplementNonExistingMethods

 /**
  * @expectedException \Mockery\Exception
  */
 public function testWetherMockWithInterfaceOnlyCanNotImplementNonExistingMethods()
 {
     \Mockery::getConfiguration()->allowMockingNonExistentMethods(false);
     $waterMock = \Mockery::mock('IWater');
     $waterMock->shouldReceive('nonExistentMethod')->once()->andReturnNull();
     \Mockery::close();
 }
开发者ID:quizlet,项目名称:mockery,代码行数:10,代码来源:ExpectationTest.php


注:本文中的Mockery::getConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。