function testCanVerifyByType() { $mock = Phockito::mock('PhockitoHamcrestTest_MockMe'); $mock->Bar('Pow!'); $mock->Bar('Bam!'); Phockito::verify($mock, 2)->Bar(stringValue()); }
function testCanVerifyByType() { $mock = Phockito::mock(MockPassMe::class); $mock->Bar('Pow!'); $mock->Bar('Bam!'); Phockito::verify($mock, 2)->Bar(stringValue()); }
function testPhockitoIntegration() { $mock = Phockito::mock('ViewableData'); Phockito::when($mock)->getField(stringValue())->return('Foo'); $this->assertEquals($mock->getField(1), null); $this->assertEquals($mock->getField('Bar'), 'Foo'); Phockito::verify($mock)->getField(integerValue()); }
public function testAccessorForCredentialsConvertsStringIntoArray() { $user = Factory::create('User', ['id' => 1]); $credentialsNotAccessed = $user->getAttributes()['credentials']; $credentialsAccessed = $user->credentials; assertThat($credentialsNotAccessed, is(stringValue())); assertThat($credentialsAccessed, is(arrayValue())); }
function getFieldValue($field) { $value = ""; switch ($field[1]) { case "string": $value = stringValue($field); break; case "picklist": $value = "varchar(100)"; case "json": break; case "boolean": $value = "bit"; break; case "number": $value = "int(11)"; break; case "decimal": $precision = 15; $postdigits = 2; if ($field[2] && $field[2] > 0) { $precision = $field[2]; } if ($field[3] && $field[3] > 0) { $postdigits = $field[3]; } $value = 'numeric(' . $precision . ',' . $postdigits . ')'; break; case "parententity": $value = "int(11)"; case "hidden": $value = "int(11)"; break; case "date": $value = "datetime"; break; case "linkedentity": $value = 'int'; break; case "linkedentities": case "childentities": break; case "custom": break; } return $value; }
public function testSendEmailAction() { $user = $this->mock('Claroline\\CoreBundle\\Entity\\User'); $form = $this->mock('Symfony\\Component\\Form\\Form'); $this->formFactory->shouldReceive('create')->once()->with(FormFactory::TYPE_USER_EMAIL, array(), null)->andReturn($form); $form->shouldReceive('handleRequest')->with($this->request)->once(); $form->shouldReceive('isValid')->once()->andReturn(true); $form->shouldReceive('getData')->once()->andReturn(array('mail' => '*****@*****.**')); $this->userManager->shouldReceive('getUserByEmail')->once()->with('*****@*****.**')->andReturn($user); $user->shouldReceive('getUsername')->once()->andReturn('toto'); $user->shouldReceive('getSalt')->once()->andReturn('fsdf'); $user->shouldReceive('setHashTime')->once()->with(intValue()); $user->shouldReceive('setResetPasswordHash')->once()->with(stringValue()); $user->shouldReceive('getResetPasswordHash')->once()->andReturn('123'); $this->om->shouldReceive('persist')->once()->with($user); $this->om->shouldReceive('flush')->once(); $this->mailManager->shouldReceive('sendForgotPassword')->once()->with($user)->andReturn(true); $form->shouldReceive('createView')->once()->andReturn('view'); $this->assertEquals(array('user' => $user, 'form' => 'view'), $this->controller->sendEmailAction()); }
public function testDecribesActualTypeInMismatchMessage() { $this->assertMismatchDescription('was null', stringValue(), null); $this->assertMismatchDescription('was a double <5.2F>', stringValue(), 5.2); }