|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-07-23 13:30 UTC] lstrojny@php.net
Description:
------------
To allow mocking with PHPUnit, PECL amqp needs to allow overriding the
constructor without calling the parent constructor. Additionally, declare is a
reserved word in PHP and therefore it is not possible to override that method in
userland.
This is the missing part to make PECL amqp usable with PHPUnit.
Test script:
---------------
<?php
class AmqpTest extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->exchange = $this->getMockBuilder('AMQPExchange')
->disableOriginalConstructor()
->getMock();
$this->queue = $this->getMockBuilder('AMQPQueue')
->disableOriginalConstructor()
->getMock();
$this->channel = $this->getMockBuilder('AMQPChannel')
->disableOriginalConstructor()
->getMock();
}
public function testCallExchangeDeclare()
{
$this->assertNull($this->exchange->declare());
}
public function testCallQueueDeclare()
{
$this->assertNull($this->queue->declare());
}
}
Expected result:
----------------
PHPUnit 3.6.11 by Sebastian Bergmann.
..
Time: 0 seconds, Memory: 6.00Mb
OK (2 tests, 2 assertions)
Actual result:
--------------
PHPUnit 3.6.11 by Sebastian Bergmann.
Segmentation fault
Patchesmocking.patch (last revision 2012-07-23 13:31 UTC by lars at strojny dot net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 02:00:01 2025 UTC |
> expects()->method('declare') actually, I meant mocking with 'declareQueue' or 'declateExchange'...