private function _setMatchingInvocationsTo($count)
 {
     $matchingInvocations = array();
     for ($i = 0; $i < $count; $i++) {
         $matchingInvocations[] = $this->_mockInvocation;
     }
     Phockito::when($this->_mockContext->getMatchingInvocations())->return($matchingInvocations);
 }
 private function _assertMessageHasStandardDetailsAndExpectation($failureMessage, $expectation)
 {
     $this->assertThat($failureMessage, $this->stringContains('method Foo'));
     $this->assertThat($failureMessage, $this->stringContains($expectation));
     $this->assertThat($failureMessage, $this->stringContains('actually called ' . count($this->_mockContext->getMatchingInvocations()) . ' times'));
     $this->assertThat($failureMessage, $this->stringContains("Wanted call:\n" . print_r($this->_wantedArgs, true)));
     $this->assertThat($failureMessage, $this->stringContains("Calls:\n" . print_r($this->_mockInvocation->args, true)));
 }
예제 #3
0
 function verify(VerificationContext $verificationContext)
 {
     foreach ($verificationContext->getAllInvocationsOnMock() as $invocation) {
         if (!$invocation->verified) {
             return new UnsuccessfulNoMoreInteractionsVerificationResult($invocation);
         }
     }
     return new SuccessfulVerificationResult();
 }
 function verify(VerificationContext $verificationContext)
 {
     $success = $this->_numberOfInvocationsSatisfiesConstraint(count($verificationContext->getMatchingInvocations()));
     if ($success) {
         return new SuccessfulVerificationResult();
     } else {
         return new UnsuccessfulNumericalVerificationResult($verificationContext, $this->_describeExpectation());
     }
 }
예제 #5
0
파일: Only.php 프로젝트: crashuxx/phockito
 function verify(VerificationContext $verificationContext)
 {
     $allInvocations = $verificationContext->getAllInvocationsOnMock();
     $matchingInvocations = $verificationContext->getMatchingInvocations();
     $allInvocationsCount = count($allInvocations);
     $matchingInvocationsCount = count($matchingInvocations);
     if ($allInvocationsCount != 1 && $matchingInvocationsCount > 0) {
         return new UnsuccessfulNoMoreInteractionsVerificationResult($matchingInvocations[0]);
     } elseif ($allInvocationsCount != 1 || $matchingInvocationsCount == 0) {
         $expectation = "called exactly once, and nothing else was";
         return new UnsuccessfulNumericalVerificationResult($verificationContext, $expectation);
     }
     return new SuccessfulVerificationResult();
 }