Re: Are there any PSR tests?

55 views
Skip to first unread message
Message has been deleted

Woody Gilk

unread,
Sep 29, 2019, 9:39:28 PM9/29/19
to PHP Framework Interoperability Group
PSR-17 has a test suite: https://github.com/http-interop/http-factory-tests

I am unsure about other PSRs.


On Sun, Sep 29, 2019 at 8:37 PM Anton Fedonjuk <antonf...@gmail.com> wrote:
Аbstract implementation or real tests at PHPUnit.
Why I ask about tests for "interfaces" without strict types (in most cases)?
Because many packages writing "Implementation of PSR-*" in description don't even suspect that is not true.
As example: half libraries based on PSR-7 returning wrong result by Psr\Http\Message::getHeaders(). They returns headers with normalized names (array keys).
Also some standarts have very abstact description, we do not need to look far for an example:
Call Psr\Http\Message::withHeader('Foo', '...')->withAddedHeader('foo', '...');
What will return method getHeaders: ['Foo' => '...', ...] or ['foo' => '...', ...]?
I don't found answer in PRS-7 :(

--
You received this message because you are subscribed to the Google Groups "PHP Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to php-fig+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/php-fig/c4d8f4d2-663f-47c0-ab82-0092b6dd522b%40googlegroups.com.

Anton Fedonjuk

unread,
Sep 29, 2019, 10:58:17 PM9/29/19
to PHP Framework Interoperability Group
A journey of a thousand packages started with a first test, thanks!

понедельник, 30 сентября 2019 г., 4:39:28 UTC+3 пользователь Woody Gilk написал:

Martijn van der Ven

unread,
Sep 30, 2019, 12:04:47 AM9/30/19
to PHP Framework Interoperability Group
The PHP HTTP Group also compiles some PSR-7 integration tests that you could look at:
Message has been deleted

Martijn van der Ven

unread,
Oct 1, 2019, 2:14:26 PM10/1/19
to PHP Framework Interoperability Group
I am unsure what you mean, Anton. Woody pointed at tests for PSR-17 while I pointed at tests for PSR-7, they test implementations of different interfaces and you should use the one that matches the interface you are implementing.

They are also not my tests. I have actually contributed more code to the tests Woody linked than to the ones I linked, including an outstanding PR about a weird under-specified issue with PSR-17 as it relates to streams (a discussion Woody has also previously been involved with). So I am not sure this is a me vs Woody’s team situation 😉

To get back to your original email though: according to the PSR-7 definition of getHeaders it should not change the original case used to define the headers. To quote:

While header names are not case-sensitive, getHeaders() will preserve the exact case in which headers were originally specified.

I would love to see a test for that added to the PSR-7 test suite I linked, so all the big PSR-7 implementations can be tested against the case you mentioned to see how they handle it. There is no test for this that I could find at a cursory glance. I would expect PSR-7 to mean it would result in ['Foo' => ['...'], 'foo' => ['...']].

On Monday, 30 September 2019 09:15:37 UTC+2, Anton Fedonjuk wrote:
Sorry but your tests bad wrong, see Woody solution - his team fix all u bugs year ago.

понедельник, 30 сентября 2019 г., 7:04:47 UTC+3 пользователь Martijn van der Ven написал:
Reply all
Reply to author
Forward
0 new messages