Skip to content

Commit

Permalink
Use a data provider for testInvalidTypes
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Apr 4, 2019
1 parent 623cbf8 commit b1aa87b
Showing 1 changed file with 11 additions and 23 deletions.
34 changes: 11 additions & 23 deletions tests/InvalidTypesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,28 @@

class InvalidTypesTest extends TestCase
{
public function testInvalidTypeDateTime() : void
{
$this->expectException(InvalidTypeException::class);
$this->expectExceptionMessage('Type "dateTime" is not a valid type.');

$schema = (object) [
'type' => 'dateTime'
];

Convert::openapiSchemaToJsonSchema($schema);
}

public function testInvalidTypeFoo() : void
/**
* @dataProvider providerInvalidTypes
*/
public function testInvalidTypes($type) : void
{
$this->expectException(InvalidTypeException::class);
$this->expectExceptionMessage('Type "foo" is not a valid type.');
$this->expectExceptionMessage('Type ' . json_encode($type) . ' is not a valid type.');

$schema = (object) [
'type' => 'foo'
'type' => $type
];

Convert::openapiSchemaToJsonSchema($schema);
}

public function testInvalidTypeNotAsString() : void
public function providerInvalidTypes() : array
{
$this->expectException(InvalidTypeException::class);
$this->expectExceptionMessage('Type ["string",null] is not a valid type.');

$schema = (object) [
'type' => ['string', null]
return [
['dateTime'],
['foo'],
[['string', null]], // 'null' should be a string
];

Convert::openapiSchemaToJsonSchema($schema);
}

public function testInvalidTypeInsideComplexSchema() : void
Expand Down

0 comments on commit b1aa87b

Please sign in to comment.