|
From: Tarjei H. <ta...@sc...> - 2011-10-30 11:26:43
|
Hi, try to run php in a debugger and see what happens. If php segfaults,
that is most probably not a simpletest issue but a problem with php.
T
On 10/29/2011 04:58 PM, Mark Slade wrote:
> 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
>>
> ------------------------------------------------------------------------------
> Get your Android app more play: Bring it to the BlackBerry PlayBook
> in minutes. BlackBerry App World™ now supports Android™ Apps
> for the BlackBerry® PlayBook™. Discover just how easy and simple
> it is! http://p.sf.net/sfu/android-dev2dev
> _______________________________________________
> Simpletest-support mailing list
> Sim...@li...
> https://lists.sourceforge.net/lists/listinfo/simpletest-support
--
Regards / Med vennlig hilsen
Tarjei Huse
Mobil: 920 63 413
|