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


PHP Mockery::hasKey方法代码示例

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


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

示例1: testBuildForm

 public function testBuildForm()
 {
     $builder = m::mock('Symfony\\Component\\Form\\FormBuilderInterface');
     $input = array('buttons' => array('save' => array('type' => 'submit', 'options' => array('label' => 'button.save')), 'cancel' => array('type' => 'button', 'options' => array('label' => 'button.cancel'))));
     $buttonBuilder = new ButtonBuilder('name');
     $builder->shouldReceive('add')->with(m::anyOf('save', 'cancel'), m::anyOf('submit', 'button'), m::hasKey('label'))->twice()->andReturn($buttonBuilder);
     $this->type = new FormActionsType();
     $this->type->buildForm($builder, $input);
 }
开发者ID:saxulum,项目名称:saxulum-bootstrap-provider,代码行数:9,代码来源:FormActionsTypeTest.php

示例2: testCreate

 public function testCreate()
 {
     Sentry::shouldReceive('createGroup')->once()->andThrow('Cartalyst\\Sentry\\Groups\\NameRequiredException');
     $this->assertFalse($this->groups->create(array()));
     Sentry::shouldReceive('createGroup')->once()->with(array('name' => 'Admin'))->andThrow('Cartalyst\\Sentry\\Groups\\GroupExistsException');
     $this->assertFalse($this->groups->create(array('name' => 'Admin')));
     $this->assertNotNull($this->groups->getError());
     Sentry::shouldReceive('createGroup')->once()->with(m::hasKey('name'))->andReturn(true);
     $this->assertTrue($this->groups->create(array('name' => '')));
     $this->assertNotNull($this->groups->getError());
 }
开发者ID:djordje,项目名称:laravel-sentry-backend,代码行数:11,代码来源:ServicesSentryGroupsTest.php

示例3: testHasKeyConstraintThrowsExceptionWhenConstraintUnmatched

 /**
  * @expectedException \Mockery\Exception
  */
 public function testHasKeyConstraintThrowsExceptionWhenConstraintUnmatched()
 {
     $this->mock->shouldReceive('foo')->with(Mockery::hasKey('c'))->once();
     $this->mock->foo(array('a' => 1, 'b' => 3));
     $this->container->mockery_verify();
 }
开发者ID:carriercomm,项目名称:CraigslistX,代码行数:9,代码来源:ExpectationTest.php

示例4: testUnbanUser

 public function testUnbanUser()
 {
     // Mock the Event::fire() calls
     $this->dispatcherMock->shouldReceive('fire')->with('sentinel.user.banned', \Mockery::hasKey('userId'))->once();
     $this->dispatcherMock->shouldReceive('fire')->with('sentinel.user.unbanned', \Mockery::hasKey('userId'))->once();
     // Find the user we are going to suspend
     $user = $this->sentry->findUserByLogin('user@user.com');
     // Prepare the Throttle Provider
     $throttleProvider = $this->sentry->getThrottleProvider();
     // Ban the user
     $this->repo->ban($user->id);
     // This is the code we are testing
     $result = $this->repo->unban($user->id);
     // Ask the Throttle Provider to gather information for this user
     $throttle = $throttleProvider->findByUserId($user->id);
     // Check the throttle status.  This should do nothing.
     $throttle->check();
     // Assertions
     $this->assertTrue($result['success']);
 }
开发者ID:periodthree,项目名称:mhd,代码行数:20,代码来源:SentryUserTest.php

示例5: testExecuteEmailChangeDoesNotChangeOthers

 public function testExecuteEmailChangeDoesNotChangeOthers()
 {
     $this->userManager->shouldReceive('getAllCampusIds')->with(false, false)->andReturn(['abc']);
     $fakeDirectoryUser = ['firstName' => 'new-first', 'lastName' => 'new-last', 'email' => 'new-email', 'telephoneNumber' => 'new-phone', 'campusId' => 'abc', 'username' => 'new-abc123'];
     $this->directory->shouldReceive('findByCampusIds')->with(['abc'])->andReturn([$fakeDirectoryUser]);
     $authentication = m::mock('Ilios\\CoreBundle\\Entity\\AuthenticationInterface')->shouldReceive('getUsername')->andReturn('abc123')->mock();
     $user = m::mock('Ilios\\CoreBundle\\Entity\\UserInterface')->shouldReceive('getId')->andReturn(42)->shouldReceive('getFirstAndLastName')->andReturn('first last')->shouldReceive('getFirstName')->andReturn('first')->shouldReceive('getLastName')->andReturn('last')->shouldReceive('getEmail')->andReturn('email')->shouldReceive('getPhone')->andReturn('phone')->shouldReceive('getCampusId')->andReturn('abc')->shouldReceive('getAuthentication')->andReturn($authentication)->shouldReceive('setExamined')->with(true)->mock();
     $this->userManager->shouldReceive('findUsersBy')->with(array('campusId' => 'abc', 'enabled' => true, 'userSyncIgnore' => false))->andReturn([$user])->once();
     $this->userManager->shouldReceive('findUsersBy')->with(m::hasKey('examined'), m::any())->andReturn([])->andReturn([])->once();
     $this->userManager->shouldReceive('updateUser')->with($user, false)->once();
     $update = m::mock('Ilios\\CoreBundle\\Entity\\PendingUserUpdate')->shouldReceive('setType')->with('emailMismatch')->once()->shouldReceive('setProperty')->with('email')->once()->shouldReceive('setValue')->with('new-email')->once()->shouldReceive('setUser')->with($user)->once()->mock();
     $this->pendingUserUpdateManager->shouldReceive('createPendingUserUpdate')->andReturn($update)->once();
     $this->pendingUserUpdateManager->shouldReceive('updatePendingUserUpdate')->with($update, false)->once();
     $this->em->shouldReceive('flush')->twice();
     $this->em->shouldReceive('clear')->once();
     $this->commandTester->execute(array('command' => self::COMMAND_NAME));
     $output = $this->commandTester->getDisplay();
     $this->assertRegExp('/Completed sync process 1 users found in the directory; 0 users updated./', $output);
 }
开发者ID:Okami-,项目名称:ilios,代码行数:19,代码来源:SyncAllUsersCommandTest.php

示例6: testDeleteProperlyDeletesModelWhenSoftDeleting

 public function testDeleteProperlyDeletesModelWhenSoftDeleting()
 {
     $model = $this->getMock('LMongo\\Eloquent\\Model', array('newQuery', 'updateTimestamps', 'touchOwners'));
     $model->setSoftDeleting(true);
     $query = m::mock('stdClass');
     $query->shouldReceive('where')->once()->with('_id', 'MongoID')->andReturn($query);
     $query->shouldReceive('update')->once()->with(m::hasKey('deleted_at'));
     $model->expects($this->once())->method('newQuery')->will($this->returnValue($query));
     $model->expects($this->once())->method('touchOwners');
     $model->exists = true;
     $model->_id = '500000000000000000000000';
     $model->delete();
 }
开发者ID:navruzm,项目名称:lmongo,代码行数:13,代码来源:LMongoEloquentModelTest.php


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