ext-php-rs icon indicating copy to clipboard operation
ext-php-rs copied to clipboard

feat: integration tests

Open TorstenDittmann opened this issue 3 years ago • 1 comments

Implemented a very basic test suite for all Datatypes that can be passed as an argument or returned.

I am not sure what kind of conventions you would like to follow here, so I kept the PHP files very stupid - same with the assertion texts. So we would need to decide on a proper way of how to pass the results from PHP to Rust.

Not a 100% happy how the PHP code is executed using a hardcoded path to the compiled extension. Nontheless, I think that is a good start for the first iteration 👍🏻

TorstenDittmann avatar Jan 13 '22 22:01 TorstenDittmann

@TorstenDittmann how are you feeling about that state of this PR? I may be able to help finish it if you're short on time.

vodik avatar Apr 11 '22 21:04 vodik

What's the status on this ? I feel like such test would be very helpful when developing this library

joelwurtz avatar Oct 17 '23 14:10 joelwurtz

What's the status on this ? I feel like such test would be very helpful when developing this library

It's the most critical feature that I want, but this PR is abandoned. IMHO, I would try to reproduce what php core does with phpt

ptondereau avatar Oct 17 '23 14:10 ptondereau

Yeah, it kinda got abandoned due to many reason.

If there is interest I can spend a weekend to probably create the PR again from scratch 👀

TorstenDittmann avatar Oct 17 '23 14:10 TorstenDittmann

IMHO, I would try to reproduce what php core does with phpt

That would be nice, it could even be used by people creating extension with this lib to test there code.

I think this would be possible if there was a possibility to compile php with code from this library under a new binary, which would also allow to create binary in rust that can execute php code (like a new sapi ?)

joelwurtz avatar Oct 17 '23 15:10 joelwurtz

That would be nice, it could even be used by people creating extension with this lib to test there code.

I think this would be possible if there was a possibility to compile php with code from this library under a new binary, which would also allow to create binary in rust that can execute php code (like a new sapi ?)

There is this experimental module here https://github.com/php/php-src/tree/master/sapi/embed to produce a single binary with the Zend engine entry point. I did a small PoC with it and Tauri to reproduce what NativePHP does: it works well. Instead of compiling into a whole extension, we could execute the tested code with it

ptondereau avatar Oct 18 '23 15:10 ptondereau

Can you share your PoC with Tauri ? i would be interested in how you did that

joelwurtz avatar Oct 18 '23 16:10 joelwurtz

I made an example on https://github.com/davidcole1340/ext-php-rs/pull/270

It works great, it even allow to put test directly in the wanted file, i will try to do a wrapper so we can execute code directly in it, thanks for the input @ptondereau about embed this is certainly the best way to go for that

joelwurtz avatar Oct 19 '23 07:10 joelwurtz