Skip to content

Commit 99f5950

Browse files
committed
Merge branch '2.0'
2 parents da77ac0 + a4a3d92 commit 99f5950

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ cache:
1010
matrix:
1111
include:
1212
- php: '7.0'
13-
- php: '7.1.0' # Prevent phpdbg's segfaults
13+
- php: '7.1'
1414
env: coverage=1 lint=1
15-
- php: '7.1.0'
15+
- php: '7.1'
1616
env: deps='low'
1717

1818
before_install:
@@ -22,7 +22,7 @@ before_install:
2222
- if [[ $coverage = 1 ]]; then mkdir -p build/logs build/cov; fi
2323
- if [[ $coverage = 1 ]]; then wget https://phar.phpunit.de/phpcov.phar; fi
2424
- if [[ $coverage = 1 ]]; then wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar; fi
25-
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.1.2/php-cs-fixer.phar; fi
25+
- if [[ $lint = 1 ]]; then wget https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.3.1/php-cs-fixer.phar; fi
2626
- if [[ $lint = 1 ]]; then composer global require phpstan/phpstan; fi
2727
- export PATH="$PATH:$HOME/.composer/vendor/bin"
2828
- echo "memory_limit=-1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
@@ -33,8 +33,8 @@ install:
3333
- if [[ $deps = 'low' ]]; then composer update --prefer-dist --no-progress --no-suggest --prefer-stable --prefer-lowest --ansi; fi
3434

3535
script:
36-
- if [[ $coverage = 1 ]]; then phpdbg -qrr vendor/bin/phpunit --colors=never --coverage-php build/cov/coverage-phpunit.cov; else vendor/bin/phpunit --colors=never; fi
37-
- if [[ $coverage = 1 ]]; then for feature in $(ls -d features/*/ | cut -f2 -d'/' | grep -v bootstrap); do FEATURE=$feature phpdbg -qrr vendor/bin/behat --profile coverage features/$feature --no-colors; done; else vendor/bin/behat --no-colors; fi
36+
- if [[ $coverage = 1 ]]; then phpdbg -qrr vendor/bin/phpunit --coverage-php build/cov/coverage-phpunit.cov; else vendor/bin/phpunit; fi
37+
- if [[ $coverage = 1 ]]; then for f in $(find features -name '*.feature'); do FEATURE=${f//\//_} phpdbg -qrr vendor/bin/behat --profile coverage $f; done; else vendor/bin/behat; fi
3838
- if [[ $coverage = 1 ]]; then phpdbg -qrr phpcov.phar merge --clover build/logs/clover.xml build/cov; fi
3939
- tests/Fixtures/app/console api:swagger:export > swagger.json && swagger validate swagger.json && rm swagger.json
4040
- if [[ $lint = 1 ]]; then php php-cs-fixer.phar fix --dry-run --diff --no-ansi; fi

src/Swagger/Serializer/DocumentationNormalizer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use ApiPlatform\Core\Api\ResourceClassResolverInterface;
2121
use ApiPlatform\Core\Api\UrlGeneratorInterface;
2222
use ApiPlatform\Core\Documentation\Documentation;
23-
use ApiPlatform\Core\Exception\RuntimeException;
2423
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
2524
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
2625
use ApiPlatform\Core\Metadata\Property\PropertyMetadata;
@@ -188,9 +187,9 @@ private function getPathOperation(string $operationName, array $operation, strin
188187
return $this->updatePutOperation($pathOperation, $mimeTypes, $operationType, $resourceMetadata, $resourceClass, $resourceShortName, $operationName, $definitions);
189188
case 'DELETE':
190189
return $this->updateDeleteOperation($pathOperation, $resourceShortName);
191-
default:
192-
throw new RuntimeException(sprintf('Method "%s" is not supported', $method));
193190
}
191+
192+
return $pathOperation;
194193
}
195194

196195
/**

tests/Swagger/Serializer/DocumentationNormalizerTest.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,11 +1078,7 @@ public function testNoOperations()
10781078
$this->assertEquals($expected, $normalizer->normalize($documentation));
10791079
}
10801080

1081-
/**
1082-
* @expectedException \ApiPlatform\Core\Exception\RuntimeException
1083-
* @expectedMessage Method "foo" is not supported
1084-
*/
1085-
public function testMethodNotSupported()
1081+
public function testWithCustomMethod()
10861082
{
10871083
$documentation = new Documentation(new ResourceNameCollection([Dummy::class]), '', '', '0.0.0', ['jsonld' => ['application/ld+json']]);
10881084

@@ -1108,6 +1104,7 @@ public function testMethodNotSupported()
11081104
$operationMethodResolverProphecy->getCollectionOperationMethod(Dummy::class, 'get')->shouldBeCalled()->willReturn('FOO');
11091105

11101106
$urlGeneratorProphecy = $this->prophesize(UrlGeneratorInterface::class);
1107+
$urlGeneratorProphecy->generate('api_entrypoint')->willReturn('/')->shouldBeCalled();
11111108

11121109
$operationPathResolver = new CustomOperationPathResolver(new UnderscoreOperationPathResolver());
11131110

@@ -1121,7 +1118,24 @@ public function testMethodNotSupported()
11211118
$urlGeneratorProphecy->reveal()
11221119
);
11231120

1124-
$normalizer->normalize($documentation);
1121+
$expected = [
1122+
'swagger' => '2.0',
1123+
'basePath' => '/',
1124+
'info' => [
1125+
'title' => '',
1126+
'version' => '0.0.0',
1127+
],
1128+
'paths' => new \ArrayObject([
1129+
'/dummies' => [
1130+
'foo' => new \ArrayObject([
1131+
'tags' => ['Dummy'],
1132+
'operationId' => 'getDummyCollection',
1133+
]),
1134+
],
1135+
]),
1136+
];
1137+
1138+
$this->assertEquals($expected, $normalizer->normalize($documentation));
11251139
}
11261140

11271141
public function testNormalizeWithNestedNormalizationGroups()

0 commit comments

Comments
 (0)