Вопрос

Is there a good API that would allow someone to create an object of Apache class?

The class itself seems to lack a constructor; and synopsis wasn't very helpful. My suspicion is that it's somehow done via sublcass, e.g. Apache::Request?

The context is I'm trying to write a test for a module which uses Embperl's $HTML::Embperl::req_rec variable (more specifically, calls the uri() method on an object contained in it). The variable, upon examination, contains an object with ref($req_rec) eq 'Apache'.

NOTE: I'm specifically asking about constructing a REAL (though not necessarily fully functional) object. NOT mocking it (which I obviously easily can do and probably will end up doing anyway).

Это было полезно?

Решение

I don't believe you can create Apache::Request objects, period. The intent is for them to be created for you by the mod_perl runtime -- they're internally bound to structures within the Apache process which may not be possible to create from perl.

If you're only doing relatively simple things with the object, you may be able to get a CGI object to do the same job. If anything complex is going on, though, there's probably little alternative besides mocking the object or testing within a live Apache instance.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top