isInstanceOf() public static method

Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object.
public static isInstanceOf ( string $className ) : PHPUnit_Framework_Constraint_IsInstanceOf
$className string
return PHPUnit_Framework_Constraint_IsInstanceOf
 /**
  * @test
  */
 public function thatHandles()
 {
     $messages = array(new Message(self::DUMMY_MESSAGE_UNIQUE_ID, self::DUMMY_MESSAGE_ID, self::DUMMY_MESSAGE_SUBJECT, self::DUMMY_MESSAGE_CONTENT, $this->getDummyFrom(), self::DUMMY_MESSAGE_TO, self::DUMMY_MESSAGE_REFERENCE));
     $strategies = array($this->strategy);
     $this->provider->expects($this->once())->method('fetchMessagesToProcess')->will($this->returnValue($messages));
     $this->strategyHolder->expects($this->once())->method('getStrategies')->will($this->returnValue($strategies));
     $this->context->expects($this->exactly(count($strategies)))->method('setStrategy')->with($this->isInstanceOf('\\Diamante\\EmailProcessingBundle\\Model\\Processing\\Strategy'));
     $this->context->expects($this->exactly(count($messages) * count($strategies)))->method('execute')->with($this->isInstanceOf('Diamante\\EmailProcessingBundle\\Model\\Message'));
     $this->provider->expects($this->once())->method('markMessagesAsProcessed')->with($this->logicalAnd($this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY), $this->countOf(count($messages)), $this->callback(function ($other) {
         $result = true;
         foreach ($other as $message) {
             $constraint = \PHPUnit_Framework_Assert::isInstanceOf('Diamante\\EmailProcessingBundle\\Model\\Message');
             try {
                 \PHPUnit_Framework_Assert::assertThat($message, $constraint);
             } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
                 $result = false;
             }
         }
         return $result;
     })));
     $this->manager->handle($this->provider);
 }
 /**
  * @test
  */
 public function thatHandlesAndMarksMessages()
 {
     $messages = $this->getMessages();
     $strategies = array($this->strategy);
     $this->settings->expects($this->any())->method('getDeleteProcessedMessages')->will($this->returnValue(false));
     $this->provider->expects($this->once())->method('fetchMessagesToProcess')->will($this->returnValue($messages));
     $this->strategyHolder->expects($this->once())->method('getStrategies')->will($this->returnValue($strategies));
     $this->context->expects($this->exactly(count($strategies)))->method('setStrategy')->with($this->isInstanceOf('\\Diamante\\EmailProcessingBundle\\Model\\Processing\\Strategy'));
     $this->context->expects($this->exactly(count($messages) * count($strategies)))->method('execute')->with($this->isInstanceOf('Diamante\\EmailProcessingBundle\\Model\\Message'));
     $this->provider->expects($this->once())->method('markMessagesAsProcessed')->with($this->logicalAnd($this->isType(\PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY), $this->countOf(count($messages)), $this->callback(function ($other) {
         $result = true;
         foreach ($other as $message) {
             $constraint = \PHPUnit_Framework_Assert::isInstanceOf('Diamante\\EmailProcessingBundle\\Model\\Message');
             try {
                 \PHPUnit_Framework_Assert::assertThat($message, $constraint);
             } catch (\PHPUnit_Framework_ExpectationFailedException $e) {
                 $result = false;
             }
         }
         return $result;
     })));
     $this->manager->handle($this->provider);
 }
Esempio n. 3
0
/**
 * Returns a PHPUnit_Framework_Constraint_IsInstanceOf matcher object.
 *
 * @param  string $className
 * @return PHPUnit_Framework_Constraint_IsInstanceOf
 * @since  Method available since Release 3.0.0
 */
function isInstanceOf($className)
{
    return PHPUnit_Framework_Assert::isInstanceOf($className);
}
 /**
  * @covers PHPUnit_Framework_Constraint_IsInstanceOf
  * @covers PHPUnit_Framework_Constraint_Not
  * @covers PHPUnit_Framework_Assert::isInstanceOf
  * @covers PHPUnit_Framework_Assert::logicalNot
  */
 public function testConstraintIsNotInstanceOf2()
 {
     $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::isInstanceOf('stdClass'));
     try {
         $constraint->fail(new stdClass(), 'custom message', TRUE);
     } catch (PHPUnit_Framework_ExpectationFailedException $e) {
         $this->assertEquals("custom message\nFailed asserting that <stdClass> is not an instance of class \"stdClass\".", $e->getDescription());
         return;
     }
     $this->fail();
 }
    /**
     * @covers PHPUnit_Framework_Constraint_IsInstanceOf
     * @covers PHPUnit_Framework_Constraint_Not
     * @covers PHPUnit_Framework_Assert::isInstanceOf
     * @covers PHPUnit_Framework_Assert::logicalNot
     * @covers PHPUnit_Framework_TestFailure::exceptionToString
     */
    public function testConstraintIsNotInstanceOf2()
    {
        $constraint = PHPUnit_Framework_Assert::logicalNot(PHPUnit_Framework_Assert::isInstanceOf('stdClass'));
        try {
            $constraint->evaluate(new stdClass(), 'custom message');
        } catch (PHPUnit_Framework_ExpectationFailedException $e) {
            $this->assertEquals(<<<EOF
custom message
Failed asserting that stdClass Object () is not an instance of class "stdClass".

EOF
, PHPUnit_Framework_TestFailure::exceptionToString($e));
            return;
        }
        $this->fail();
    }
 /**
  * @Then a schlami shows up
  */
 public function aSchlamiShowsUp()
 {
     $this->_schlami = new Schlami();
     Assert::isInstanceOf(Schlami::class, $this->_schlami);
 }