File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,12 @@ final class TestDoubleFactory
2020{
2121 public static function createResponse (array $ body , array $ header = []) : Response
2222 {
23+ $ header = array_replace ([
24+ Keys::CODE => 0 ,
25+ Keys::SYNC => 1 ,
26+ Keys::SCHEMA_ID => 0 ,
27+ ], $ header );
28+
2329 return new Response ($ header , $ body );
2430 }
2531
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * This file is part of the tarantool/phpunit-extras package.
5+ *
6+ * (c) Eugene Leonovich <gen.work@gmail.com>
7+ *
8+ * For the full copyright and license information, please view the LICENSE
9+ * file that was distributed with this source code.
10+ */
11+
12+ declare (strict_types=1 );
13+
14+ namespace Tarantool \PhpUnit \Tests \Client ;
15+
16+ use PHPUnit \Framework \TestCase ;
17+ use Tarantool \Client \Keys ;
18+ use Tarantool \PhpUnit \Client \TestDoubleFactory ;
19+
20+ final class TestDoubleFactoryTest extends TestCase
21+ {
22+ public function testResponseIncludesRequiredHeaderFieldsByDefault () : void
23+ {
24+ $ response = TestDoubleFactory ::createResponse ([]);
25+
26+ self ::assertSame (0 , $ response ->getCode ());
27+ self ::assertSame (1 , $ response ->getSync ());
28+ self ::assertSame (0 , $ response ->getSchemaId ());
29+ }
30+
31+ public function testCallerHeaderFieldsOverrideDefaults () : void
32+ {
33+ $ response = TestDoubleFactory ::createResponse ([], [
34+ Keys::CODE => 7 ,
35+ Keys::SYNC => 42 ,
36+ Keys::SCHEMA_ID => 9 ,
37+ ]);
38+
39+ self ::assertSame (7 , $ response ->getCode ());
40+ self ::assertSame (42 , $ response ->getSync ());
41+ self ::assertSame (9 , $ response ->getSchemaId ());
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments