简体   繁体   中英

How to make a mock server for PHPUnit stream testing?

A part of my project does HTTP interaction with another server, ie, it uses fopen() with a URL. As a part of that, stream contexts are used to trigger TLS authentication. I'd like to have unit tests test this to make sure TLS verification occurs properly.

So basically is there any way to create a mock server in PHP or PHPUnit so that I can purposely inject a fake TLS certificate during the fopen() call and test to make sure an error is thrown?

您可以使用GuzzlePHP,有关更多详细信息,请参见http://www.sitepoint.com/unit-testing-guzzlephp/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM