Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace PhpAmqpLib\Tests\Functional\Channel; use PhpAmqpLib\Message\AMQPMessage;..

Decoded Output download

<?php

namespace PhpAmqpLib\Tests\Functional\Channel;

use PhpAmqpLib\Message\AMQPMessage;
use PhpAmqpLib\Wire\AMQPTable;

/**
 * @group connection
 */
class HeadersExchangeTest extends ChannelTestCase
{
    protected function setUpCompat()
    {
        parent::setUpCompat();
        $this->exchange->name = 'amq.headers';
    }

    /**
     * @test
     * @small
     * @covers \PhpAmqpLib\Channel\AMQPChannel::queue_bind()
     * @covers \PhpAmqpLib\Exchange\AMQPExchangeType
     */
    public function consume_specific_headers()
    {
        list($queue1) = $this->channel->queue_declare();
        $this->channel->queue_bind($queue1, $this->exchange->name);

        $bindArguments = [
            'foo' => 'bar',
        ];
        list($queue2) = $this->channel->queue_declare();
        $this->channel->queue_bind($queue2, $this->exchange->name, '', false, new AMQPTable($bindArguments));

        // publish message without headers - should appear in 1st queue without filters
        $message = new AMQPMessage('test');
        $this->channel->basic_publish($message, $this->exchange->name);

        $received1 = $this->channel->basic_get($queue1, true);
        $received2 = $this->channel->basic_get($queue2, true);

        $this->assertInstanceOf(AMQPMessage::class, $received1);
        $this->assertNull($received2);

        // publish message with matching headers
        $message->set('application_headers', new AMQPTable($bindArguments));
        $this->channel->basic_publish($message, $this->exchange->name);

        $received1 = $this->channel->basic_get($queue1, true);
        $received2 = $this->channel->basic_get($queue2, true);

        // should appear in both queues
        $this->assertInstanceOf(AMQPMessage::class, $received1);
        $this->assertInstanceOf(AMQPMessage::class, $received2);

        // publish with not matching headers
        $message->set('application_headers', new AMQPTable(array('foo' => false)));
        $this->channel->basic_publish($message, $this->exchange->name);

        $received1 = $this->channel->basic_get($queue1, true);
        $received2 = $this->channel->basic_get($queue2, true);

        // should appear in non filtered queue only
        $this->assertInstanceOf(AMQPMessage::class, $received1);
        $this->assertNull($received2);
    }
}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace PhpAmqpLib\Tests\Functional\Channel;

use PhpAmqpLib\Message\AMQPMessage;
use PhpAmqpLib\Wire\AMQPTable;

/**
 * @group connection
 */
class HeadersExchangeTest extends ChannelTestCase
{
    protected function setUpCompat()
    {
        parent::setUpCompat();
        $this->exchange->name = 'amq.headers';
    }

    /**
     * @test
     * @small
     * @covers \PhpAmqpLib\Channel\AMQPChannel::queue_bind()
     * @covers \PhpAmqpLib\Exchange\AMQPExchangeType
     */
    public function consume_specific_headers()
    {
        list($queue1) = $this->channel->queue_declare();
        $this->channel->queue_bind($queue1, $this->exchange->name);

        $bindArguments = [
            'foo' => 'bar',
        ];
        list($queue2) = $this->channel->queue_declare();
        $this->channel->queue_bind($queue2, $this->exchange->name, '', false, new AMQPTable($bindArguments));

        // publish message without headers - should appear in 1st queue without filters
        $message = new AMQPMessage('test');
        $this->channel->basic_publish($message, $this->exchange->name);

        $received1 = $this->channel->basic_get($queue1, true);
        $received2 = $this->channel->basic_get($queue2, true);

        $this->assertInstanceOf(AMQPMessage::class, $received1);
        $this->assertNull($received2);

        // publish message with matching headers
        $message->set('application_headers', new AMQPTable($bindArguments));
        $this->channel->basic_publish($message, $this->exchange->name);

        $received1 = $this->channel->basic_get($queue1, true);
        $received2 = $this->channel->basic_get($queue2, true);

        // should appear in both queues
        $this->assertInstanceOf(AMQPMessage::class, $received1);
        $this->assertInstanceOf(AMQPMessage::class, $received2);

        // publish with not matching headers
        $message->set('application_headers', new AMQPTable(array('foo' => false)));
        $this->channel->basic_publish($message, $this->exchange->name);

        $received1 = $this->channel->basic_get($queue1, true);
        $received2 = $this->channel->basic_get($queue2, true);

        // should appear in non filtered queue only
        $this->assertInstanceOf(AMQPMessage::class, $received1);
        $this->assertNull($received2);
    }
}

Function Calls

None

Variables

None

Stats

MD5 a3061a15957af483322b68c32a7dfa83
Eval Count 0
Decode Time 85 ms