Skip to content

Commit 2558069

Browse files
committed
Add passing test
1 parent f394045 commit 2558069

File tree

3 files changed

+133
-7
lines changed

3 files changed

+133
-7
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
return [
4+
'openApiPath' => '@specs/issue_fix/162_bug_dollarref_with_x_faker/162_bug_dollarref_with_x_faker.yaml',
5+
'generateUrls' => true,
6+
'generateModels' => true,
7+
'excludeModels' => [
8+
'Error',
9+
],
10+
'generateControllers' => true,
11+
'generateMigrations' => true,
12+
'generateModelFaker' => true, // `generateModels` must be `true` in orde to use `generateModelFaker` as `true`
13+
];
14+
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
openapi: 3.0.3
2+
# Edit this schema and start your project
3+
# This is sample schema
4+
# To generate code which is based on this schema
5+
# run commands mentioned Development section in README.md file
6+
info:
7+
title: 'Proxy-Service'
8+
description: ""
9+
version: 1.0.0
10+
contact:
11+
name: '...'
12+
email: you@example.com
13+
servers:
14+
- url: 'http://localhost:9937'
15+
description: 'Local Dev API'
16+
17+
components:
18+
schemas:
19+
Contact:
20+
type: object
21+
required:
22+
- id
23+
properties:
24+
id:
25+
type: integer
26+
responses:
27+
Contact:
28+
description: 'Returns one contact by ID.'
29+
content:
30+
application/vnd.api+json:
31+
schema:
32+
type: object
33+
properties:
34+
data:
35+
$ref: '#/components/schemas/Contact'
36+
Contacts:
37+
description: 'Returns contacts.'
38+
content:
39+
application/vnd.api+json:
40+
schema:
41+
type: object
42+
properties:
43+
data:
44+
type: array
45+
items:
46+
$ref: '#/components/schemas/Contact'
47+
48+
49+
50+
paths:
51+
'/account/{accountId}/contacts':
52+
parameters:
53+
- name: accountId
54+
in: path
55+
description: ID of Account.
56+
required: true
57+
schema:
58+
type: integer
59+
60+
get:
61+
operationId: listAccountContacts
62+
summary: List all Account's contacts
63+
description: Returns all contacts for a account.
64+
responses:
65+
'200':
66+
$ref: '#/components/responses/Contacts'
67+
'403':
68+
description: Response if the currently authenticated user has no access to this Account.
69+
tags:
70+
- Contacts
71+
72+
'/account/{accountId}/contacts/{contactId}':
73+
parameters:
74+
- name: accountId
75+
in: path
76+
description: ID of Account.
77+
required: true
78+
schema:
79+
type: integer
80+
- name: contactId
81+
in: path
82+
description: ID of Contact.
83+
required: true
84+
schema:
85+
type: integer
86+
87+
get:
88+
operationId: getAccountContact
89+
summary: List a Account's contact
90+
description: Returns a contacts for a account specified by ID.
91+
responses:
92+
'200':
93+
$ref: '#/components/responses/Contact'
94+
'403':
95+
description: Response if the currently authenticated user has no access to this Account.
96+
tags:
97+
- Contacts

tests/unit/IssueFixTest.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
namespace tests\unit;
44

5-
use Yii;
65
use tests\DbTestCase;
6+
use Yii;
7+
use yii\base\InvalidArgumentException;
78
use yii\helpers\FileHelper;
89

910
// This class contains tests for various issues present at GitHub
@@ -49,12 +50,12 @@ public function testFloatIssue()
4950
$this->createTableForFloatIssue();
5051
$testFile = Yii::getAlias("@specs/issue_fix/float_issue/float_issue.php");
5152
$this->runGenerator($testFile, 'pgsql');
52-
$this->expectException(\yii\base\InvalidArgumentException::class);
53-
FileHelper::findDirectories(Yii::getAlias('@app').'/migration');
54-
FileHelper::findDirectories(Yii::getAlias('@app').'/migrations');
55-
FileHelper::findDirectories(Yii::getAlias('@app').'/migrations_mysql_db');
56-
FileHelper::findDirectories(Yii::getAlias('@app').'/migrations_maria_db');
57-
FileHelper::findDirectories(Yii::getAlias('@app').'/migrations_pgsql_db');
53+
$this->expectException(InvalidArgumentException::class);
54+
FileHelper::findDirectories(Yii::getAlias('@app') . '/migration');
55+
FileHelper::findDirectories(Yii::getAlias('@app') . '/migrations');
56+
FileHelper::findDirectories(Yii::getAlias('@app') . '/migrations_mysql_db');
57+
FileHelper::findDirectories(Yii::getAlias('@app') . '/migrations_maria_db');
58+
FileHelper::findDirectories(Yii::getAlias('@app') . '/migrations_pgsql_db');
5859
$this->deleteTables();
5960
}
6061

@@ -285,4 +286,18 @@ public function test162BugDollarrefWithXFaker()
285286
]);
286287
$this->checkFiles($actualFiles, $expectedFiles);
287288
}
289+
290+
// 163_generator_crash_when_using_reference_inside_an_object
291+
public function test163GeneratorCrashWhenUsingReferenceInsideAnObject()
292+
{
293+
$testFile = Yii::getAlias("@specs/issue_fix/163_generator_crash_when_using_reference_inside_an_object/index.php");
294+
$this->runGenerator($testFile, 'mysql');
295+
// $actualFiles = FileHelper::findFiles(Yii::getAlias('@app'), [
296+
// 'recursive' => true,
297+
// ]);
298+
// $expectedFiles = FileHelper::findFiles(Yii::getAlias("@specs/issue_fix/163_generator_crash_when_using_reference_inside_an_object/app"), [
299+
// 'recursive' => true,
300+
// ]);
301+
// $this->checkFiles($actualFiles, $expectedFiles);
302+
}
288303
}

0 commit comments

Comments
 (0)