PHPUnit_Framework_Assert::assertSame PHP Method

assertSame() public static method

Used on objects, it asserts that two variables reference the same object.
public static assertSame ( mixed $expected, mixed $actual, string $message = '' )
$expected mixed
$actual mixed
$message string
    public static function assertSame($expected, $actual, $message = '')
    {
        if (is_bool($expected) && is_bool($actual)) {
            static::assertEquals($expected, $actual, $message);
        } else {
            $constraint = new PHPUnit_Framework_Constraint_IsIdentical($expected);
            static::assertThat($actual, $constraint, $message);
        }
    }

Usage Example

 /**
  * Check if the message is requeued or not correctly.
  *
  * @dataProvider processMessageProvider
  */
 public function testProcessMessage($processFlag, $expectedMethod, $expectedRequeue = null)
 {
     $amqpConnection = $this->getMockBuilder('\\PhpAmqpLib\\Connection\\AMQPConnection')->disableOriginalConstructor()->getMock();
     $amqpChannel = $this->getMockBuilder('\\PhpAmqpLib\\Channel\\AMQPChannel')->disableOriginalConstructor()->getMock();
     $consumer = new Consumer($amqpConnection, $amqpChannel);
     $callbackFunction = function () use($processFlag) {
         return $processFlag;
     };
     // Create a callback function with a return value set by the data provider.
     $consumer->setCallback($callbackFunction);
     // Create a default message
     $amqpMessage = new AMQPMessage('foo body');
     $amqpMessage->delivery_info['channel'] = $amqpChannel;
     $amqpMessage->delivery_info['delivery_tag'] = 0;
     $amqpChannel->expects($this->any())->method('basic_reject')->will($this->returnCallback(function ($delivery_tag, $requeue) use($expectedMethod, $expectedRequeue) {
         \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_reject');
         // Check if this function should be called.
         \PHPUnit_Framework_Assert::assertSame($requeue, $expectedRequeue);
         // Check if the message should be requeued.
     }));
     $amqpChannel->expects($this->any())->method('basic_ack')->will($this->returnCallback(function ($delivery_tag) use($expectedMethod) {
         \PHPUnit_Framework_Assert::assertSame($expectedMethod, 'basic_ack');
         // Check if this function should be called.
     }));
     $consumer->processMessage($amqpMessage);
 }
All Usage Examples Of PHPUnit_Framework_Assert::assertSame
PHPUnit_Framework_Assert