-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
167 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flat3\Lodata\Tests\Protocol; | ||
|
||
use Flat3\Lodata\Tests\TestCase; | ||
use Flat3\Lodata\Transaction\MediaType; | ||
|
||
class MediaTypeTest extends TestCase | ||
{ | ||
public function typeProvider() | ||
{ | ||
return [ | ||
[ | ||
'application/json', | ||
'application/json', | ||
'application', | ||
'json', | ||
], | ||
[ | ||
'text/plain; charset=UTF-8', | ||
'text/plain;charset=UTF-8', | ||
'text', | ||
'plain', | ||
['charset' => 'UTF-8'], | ||
], | ||
[ | ||
'multipart/mixed;param=true', | ||
'multipart/mixed;param=true', | ||
'multipart', | ||
'mixed', | ||
['param' => 'true'], | ||
], | ||
[ | ||
'multipart/mixed; param=true', | ||
'multipart/mixed;param=true', | ||
'multipart', | ||
'mixed', | ||
['param' => 'true'], | ||
], | ||
[ | ||
'multipart/mixed; param=true; this=false', | ||
'multipart/mixed;param=true;this=false', | ||
'multipart', | ||
'mixed', | ||
['param' => 'true', 'this' => 'false'], | ||
], | ||
]; | ||
} | ||
|
||
/** | ||
* @dataProvider typeProvider | ||
*/ | ||
public function test_types( | ||
string $original, | ||
string $normalised, | ||
string $type, | ||
string $subtype, | ||
array $parameters = [] | ||
) { | ||
$mt = (new MediaType)->parse($original); | ||
$this->assertEquals($type, $mt->getType()); | ||
$this->assertEquals($subtype, $mt->getSubtype()); | ||
|
||
foreach ($parameters as $key => $value) { | ||
$this->assertEquals($value, $mt->getParameter($key)); | ||
} | ||
|
||
$this->assertEquals($normalised, (string) $mt); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Flat3\Lodata\Tests\Queries; | ||
|
||
use Flat3\Lodata\EntityType; | ||
use Flat3\Lodata\Facades\Lodata; | ||
use Flat3\Lodata\Singleton; | ||
use Flat3\Lodata\Tests\Helpers\Request; | ||
use Flat3\Lodata\Tests\TestCase; | ||
use Flat3\Lodata\Transaction\MediaType; | ||
use Flat3\Lodata\Type; | ||
|
||
class ValueTest extends TestCase | ||
{ | ||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$type = (new EntityType('stype')) | ||
->addDeclaredProperty('sprop', Type::string()); | ||
$entity = new Singleton('stest', $type); | ||
$entity['sprop'] = 'svalue'; | ||
Lodata::add($entity); | ||
} | ||
|
||
public function test_raw_custom_accept() | ||
{ | ||
$this->assertResponseSnapshot( | ||
(new Request) | ||
->header('accept', 'application/octet-stream') | ||
->path('/stest/sprop/$value') | ||
); | ||
} | ||
|
||
public function test_raw_custom_format() | ||
{ | ||
$this->assertResponseSnapshot( | ||
(new Request) | ||
->format('application/octet-stream') | ||
->path('/stest/sprop/$value') | ||
); | ||
} | ||
|
||
public function test_raw_no_accept() | ||
{ | ||
$this->assertResponseSnapshot( | ||
(new Request) | ||
->accept('') | ||
->path('/stest/sprop/$value') | ||
); | ||
} | ||
|
||
public function test_raw_accept_any() | ||
{ | ||
$this->assertResponseSnapshot( | ||
(new Request) | ||
->accept(MediaType::any) | ||
->path('/stest/sprop/$value') | ||
); | ||
} | ||
} |
5 changes: 0 additions & 5 deletions
5
tests/__snapshots__/Entity/KeyedCollectionTest__test_raw_custom_accept__1.yml
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
tests/__snapshots__/Entity/KeyedCollectionTest__test_raw_custom_format__1.yml
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
tests/__snapshots__/Entity/NumericCollectionTest__test_raw_custom_accept__1.yml
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
tests/__snapshots__/Entity/NumericCollectionTest__test_raw_custom_format__1.yml
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
tests/__snapshots__/Entity/RedisTest__test_raw_custom_accept__1.yml
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
tests/__snapshots__/Entity/RedisTest__test_raw_custom_format__1.yml
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
tests/__snapshots__/Entity/SQLTest__test_raw_custom_accept__1.yml
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
tests/__snapshots__/Entity/SQLTest__test_raw_custom_format__1.yml
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
tests/__snapshots__/Protocol/ErrorReportingTest__test_stream_buffered_error__2.yml
This file was deleted.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
...oquentTest__test_raw_custom_accept__1.yml → ...ies/ValueTest__test_raw_accept_any__1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
headers: | ||
cache-control: ['no-cache, private'] | ||
content-type: [application/octet-stream] | ||
content-type: [text/plain;charset=utf-8] | ||
odata-version: ['4.01'] | ||
status: 200 |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...oquentTest__test_raw_custom_format__1.yml → ...ries/ValueTest__test_raw_no_accept__1.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
headers: | ||
cache-control: ['no-cache, private'] | ||
content-type: [application/octet-stream] | ||
content-type: [text/plain;charset=utf-8] | ||
odata-version: ['4.01'] | ||
status: 200 |