|
From: Mark S. <mar...@gm...> - 2011-10-29 14:58:19
|
I realized last night that I neglected to include the important stuff:
PHP version is 5.1.6, SimpleTest version is 1.1alpha3.
On Fri, Oct 28, 2011 at 9:19 PM, Mark Slade <mar...@gm...> wrote:
> Hi,
>
> I ran into a problem when writing up some test cases. I'm new to
> SimpleTest, so I'm not sure if this is me abusing SimpleTest or a bug
> and wanted to run it by the list for some feedback.
>
> What I encountered was that if I create a mock object, and call
> expectOnce with a data structure that refers back to that mock object,
> I get a segmentation fault. The proof of concept is below.
>
> ==== >8 =================================
> <?php
>
> require_once 'simpletest/autorun.php';
>
> class PocClass
> {
> function go($in)
> {
> }
> }
>
> class TestPocClass extends UnitTestCase
> {
> function testPoc()
> {
> Mock::generate('PocClass');
> $poc = new MockPocClass;
> $in = new stdClass;
> $in->poc = $poc;
> $poc->expectOnce('go', array($in));
> $poc->go($in);
> }
> }
>
> ?>
>
> $ php poc.php
> poc.php
> Segmentation fault
> ==== >8 =================================
>
> Is there a way to accomplish what I'm trying to do here? My actual
> test case is more complex than this but the idea's the same. I have a
> parser object, that parses special markup using handler objects.
> Those handler objects are added to the parser, and when the parser
> invokes them to handle some markup, it passes in contextual
> information including a reference to itself. This is necessary as a
> single handler may be added to multiple parsers, so the handler needs
> a reference to the parser that invoked it (and that parser will also
> contain that handler).
>
> My test case creates a mock handler, adds it to the parser, then asks
> the parser to parse a string. I'm using expectOnce to make sure that
> the parser calls the handler with the expected context.
>
> Thanks,
> Mark
>
|