Skip to content

Commit 768bab8

Browse files
committed
Fix a notice using Enum. Refactor command's tests.
1 parent 4a26288 commit 768bab8

9 files changed

+1126
-37
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ install:
2525

2626
script:
2727
- phpunit
28-
- tests/run-tests.sh
2928

3029
deploy:
3130
provider: releases

composer.json

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,19 @@
2020
"require": {
2121
"php": ">=5.4",
2222
"ext-json": "*",
23-
"symfony/console": "~2.5|~3.0",
24-
"symfony/yaml": "~2.4|~3.0",
25-
"symfony/config": "~2.4|~3.0",
26-
"twig/twig": "~1.0",
27-
"psr/log": "~1.0",
28-
"easyrdf/easyrdf": "~0.9.0",
29-
"league/html-to-markdown": "~4.0",
30-
"friendsofphp/php-cs-fixer": "~1.0"
23+
"symfony/console": "^2.7 || ^3.0",
24+
"symfony/yaml": "^2.7 || ^3.0",
25+
"symfony/config": "^2.7 || ^3.0",
26+
"twig/twig": "^1.0",
27+
"psr/log": "^1.0",
28+
"easyrdf/easyrdf": "^0.9",
29+
"league/html-to-markdown": "^4.0",
30+
"friendsofphp/php-cs-fixer": "^1.0"
3131
},
3232
"require-dev": {
33-
"doctrine/orm": "~2.2",
34-
"symfony/validator": "~2.6"
33+
"doctrine/orm": "^2.2",
34+
"symfony/validator": "^2.7",
35+
"symfony/filesystem": "^2.7"
3536
},
3637
"suggest": {
3738
"myclabs/php-enum": "For enumerations",

src/TypesGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public function generate(array $config)
266266
}
267267

268268
// When including all properties, ignore properties already set on parent
269-
if (isset($config['types'][$class['name']]['allProperties']) && $config['types'][$class['name']]['allProperties'] && $class['parent']) {
269+
if (isset($config['types'][$class['name']]['allProperties']) && $config['types'][$class['name']]['allProperties'] && isset($classes[$class['parent']])) {
270270
$type = $class['resource'];
271271

272272
foreach ($propertiesMap[$type->getUri()] as $property) {

tests/AnnotationGenerator/ApiPlatformCoreAnnotationGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace ApiPlatform\SchemaGenerator\tests\AnnotationGenerator;
12+
namespace ApiPlatform\SchemaGenerator\Tests\AnnotationGenerator;
1313

1414
use ApiPlatform\SchemaGenerator\AnnotationGenerator\ApiPlatformCoreAnnotationGenerator;
1515
use ApiPlatform\SchemaGenerator\TypesGenerator;
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
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+
namespace ApiPlatform\SchemaGenerator\Tests;
13+
14+
use ApiPlatform\SchemaGenerator\Command\DumpConfigurationCommand;
15+
use Symfony\Component\Console\Tester\CommandTester;
16+
17+
/**
18+
* @author Kévin Dunglas <[email protected]>
19+
*/
20+
class DumpConfigurationTest extends \PHPUnit_Framework_TestCase
21+
{
22+
public function testDumpConfiguration()
23+
{
24+
$commandTester = new CommandTester(new DumpConfigurationCommand());
25+
$this->assertEquals(0, $commandTester->execute([]));
26+
$this->assertEquals(<<<YAML
27+
config:
28+
29+
# RDFa files
30+
rdfa:
31+
32+
# RDFa URI to use
33+
uri: 'http://schema.org/docs/schema_org_rdfa.html' # Example: http://schema.org/docs/schema_org_rdfa.html
34+
35+
# RDFa URI data format
36+
format: null # Example: rdfxml
37+
38+
# OWL relation files to use
39+
relations:
40+
41+
# Default:
42+
- http://purl.org/goodrelations/v1.owl
43+
44+
# Debug mode
45+
debug: false
46+
47+
# Automatically add an id field to entities
48+
generateId: true
49+
50+
# Generate interfaces and use Doctrine's Resolve Target Entity feature
51+
useInterface: false
52+
53+
# Emit a warning if a property is not derived from GoodRelations
54+
checkIsGoodRelations: false
55+
56+
# A license or any text to use as header of generated files
57+
header: false # Example: // (c) Kévin Dunglas <[email protected]>
58+
59+
# PHP namespaces
60+
namespaces:
61+
62+
# The namespace of the generated entities
63+
entity: SchemaOrg\Entity # Example: Acme\Entity
64+
65+
# The namespace of the generated enumerations
66+
enum: SchemaOrg\Enum # Example: Acme\Enum
67+
68+
# The namespace of the generated interfaces
69+
interface: SchemaOrg\Model # Example: Acme\Model
70+
71+
# Doctrine
72+
doctrine:
73+
74+
# Use Doctrine's ArrayCollection instead of standard arrays
75+
useCollection: true
76+
77+
# The Resolve Target Entity Listener config file pass
78+
resolveTargetEntityConfigPath: null
79+
80+
# The value of the phpDoc's @author annotation
81+
author: false # Example: Kévin Dunglas <[email protected]>
82+
83+
# Visibility of entities fields
84+
fieldVisibility: private # One of "private"; "protected"; "public"
85+
86+
# Schema.org's types to use
87+
types:
88+
89+
# Prototype
90+
id:
91+
92+
# Namespace of the vocabulary the type belongs to.
93+
vocabularyNamespace: 'http://schema.org/'
94+
95+
# Is the class abstract? (null to guess)
96+
abstract: null
97+
98+
# Is the class embeddable?
99+
embeddable: false
100+
101+
# Type namespaces
102+
namespaces:
103+
104+
# The namespace for the generated class (override any other defined namespace)
105+
class: null
106+
107+
# The namespace for the generated interface (override any other defined namespace)
108+
interface: null
109+
doctrine:
110+
111+
# The Doctrine inheritance mapping type (override the guessed one)
112+
inheritanceMapping: null
113+
114+
# The parent class, set to false for a top level class
115+
parent: null
116+
117+
# If declaring a custom class, this will be the class from which properties type will be guessed
118+
guessFrom: Thing
119+
120+
# Import all existing properties
121+
allProperties: false
122+
123+
# Properties of this type to use
124+
properties:
125+
126+
# Prototype
127+
id:
128+
129+
# The property range
130+
range: null # Example: Offer
131+
132+
# The relation table name
133+
relationTableName: null # Example: organization_member
134+
cardinality: unknown # One of "(0..1)"; "(0..*)"; "(1..1)"; "(1..*)"; "(*..0)"; "(*..1)"; "(*..*)"; "unknown"
135+
136+
# The doctrine column annotation content
137+
ormColumn: null # Example: type="decimal", precision=5, scale=1, options={"comment" = "my comment"}
138+
139+
# Symfony Serialization Groups
140+
groups: []
141+
142+
# The property nullable
143+
nullable: true
144+
145+
# The property unique
146+
unique: false
147+
148+
# Is the property embedded?
149+
embedded: false
150+
151+
# The property columnPrefix
152+
columnPrefix: false
153+
154+
# Annotation generators to use
155+
annotationGenerators:
156+
157+
# Defaults:
158+
- ApiPlatform\SchemaGenerator\AnnotationGenerator\PhpDocAnnotationGenerator
159+
- ApiPlatform\SchemaGenerator\AnnotationGenerator\ConstraintAnnotationGenerator
160+
- ApiPlatform\SchemaGenerator\AnnotationGenerator\DoctrineOrmAnnotationGenerator
161+
162+
163+
YAML
164+
, $commandTester->getDisplay());
165+
}
166+
}

0 commit comments

Comments
 (0)