Skip to content

Commit 9b8a0bd

Browse files
committed
Merge remote-tracking branch 'origin/master' into feat-dependency-upgrades-2
2 parents 18181c2 + cdcfb4b commit 9b8a0bd

14 files changed

+607
-7
lines changed

src/SDK/Language/Deno.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,41 @@ public function getFiles(): array
3333
'destination' => 'src/permission.ts',
3434
'template' => 'deno/src/permission.ts.twig',
3535
],
36+
[
37+
'scope' => 'default',
38+
'destination' => 'test/permission.test.ts',
39+
'template' => 'deno/test/permission.test.ts.twig',
40+
],
3641
[
3742
'scope' => 'default',
3843
'destination' => 'src/role.ts',
3944
'template' => 'deno/src/role.ts.twig',
4045
],
46+
[
47+
'scope' => 'default',
48+
'destination' => 'test/role.test.ts',
49+
'template' => 'deno/test/role.test.ts.twig',
50+
],
4151
[
4252
'scope' => 'default',
4353
'destination' => 'src/id.ts',
4454
'template' => 'deno/src/id.ts.twig',
4555
],
56+
[
57+
'scope' => 'default',
58+
'destination' => 'test/id.test.ts',
59+
'template' => 'deno/test/id.test.ts.twig',
60+
],
4661
[
4762
'scope' => 'default',
4863
'destination' => 'src/query.ts',
4964
'template' => 'deno/src/query.ts.twig',
5065
],
66+
[
67+
'scope' => 'default',
68+
'destination' => 'test/query.test.ts',
69+
'template' => 'deno/test/query.test.ts.twig',
70+
],
5171
[
5272
'scope' => 'default',
5373
'destination' => 'src/inputFile.ts',
@@ -73,6 +93,11 @@ public function getFiles(): array
7393
'destination' => '/src/services/{{service.name | caseDash}}.ts',
7494
'template' => 'deno/src/services/service.ts.twig',
7595
],
96+
[
97+
'scope' => 'service',
98+
'destination' => '/test/services/{{service.name | caseDash}}.test.ts',
99+
'template' => 'deno/test/services/service.test.ts.twig',
100+
],
76101
[
77102
'scope' => 'default',
78103
'destination' => 'README.md',

src/SDK/Language/PHP.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,21 +177,41 @@ public function getFiles(): array
177177
'destination' => 'src/{{ spec.title | caseUcfirst}}/Permission.php',
178178
'template' => 'php/src/Permission.php.twig',
179179
],
180+
[
181+
'scope' => 'default',
182+
'destination' => 'tests/{{ spec.title | caseUcfirst}}/PermissionTest.php',
183+
'template' => 'php/tests/PermissionTest.php.twig',
184+
],
180185
[
181186
'scope' => 'default',
182187
'destination' => 'src/{{ spec.title | caseUcfirst}}/Role.php',
183188
'template' => 'php/src/Role.php.twig',
184189
],
190+
[
191+
'scope' => 'default',
192+
'destination' => 'tests/{{ spec.title | caseUcfirst}}/RoleTest.php',
193+
'template' => 'php/tests/RoleTest.php.twig',
194+
],
185195
[
186196
'scope' => 'default',
187197
'destination' => 'src/{{ spec.title | caseUcfirst}}/ID.php',
188198
'template' => 'php/src/ID.php.twig',
189199
],
200+
[
201+
'scope' => 'default',
202+
'destination' => 'tests/{{ spec.title | caseUcfirst}}/IDTest.php',
203+
'template' => 'php/tests/IDTest.php.twig',
204+
],
190205
[
191206
'scope' => 'default',
192207
'destination' => 'src/{{ spec.title | caseUcfirst}}/Query.php',
193208
'template' => 'php/src/Query.php.twig',
194209
],
210+
[
211+
'scope' => 'default',
212+
'destination' => 'tests/{{ spec.title | caseUcfirst}}/QueryTest.php',
213+
'template' => 'php/tests/QueryTest.php.twig',
214+
],
195215
[
196216
'scope' => 'default',
197217
'destination' => 'src/{{ spec.title | caseUcfirst}}/InputFile.php',
@@ -212,6 +232,11 @@ public function getFiles(): array
212232
'destination' => '/src/{{ spec.title | caseUcfirst}}/Services/{{service.name | caseUcfirst}}.php',
213233
'template' => 'php/src/Services/Service.php.twig',
214234
],
235+
[
236+
'scope' => 'service',
237+
'destination' => '/tests/{{ spec.title | caseUcfirst}}/Services/{{service.name | caseUcfirst}}Test.php',
238+
'template' => 'php/tests/Services/ServiceTest.php.twig',
239+
],
215240
];
216241
}
217242

templates/deno/src/exception.ts.twig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
export class {{ spec.title | caseUcfirst}}Exception {
2-
message: String;
3-
code: Number;
2+
message: string;
3+
code: number;
44
response: any;
5-
type: String;
5+
type: string;
66

7-
constructor(message: String, code: Number = 0, type: String = "", response: any = "") {
7+
constructor(message: string, code: number = 0, type: string = "", response: any = "") {
88
this.message = message;
99
this.code = code;
1010
this.type = type;
1111
this.response = response;
1212
}
1313

14-
public toString(): String {
14+
public toString(): string {
1515
return `${this.message} - ${this.code} - ${this.type} - ${JSON.stringify(this.response)}`;
1616
}
17-
}
17+
}

templates/deno/test/id.test.ts.twig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import {assertEquals} from "https://deno.land/[email protected]/assert/mod.ts";
2+
import {describe, it as test} from "https://deno.land/[email protected]/testing/bdd.ts";
3+
import {ID} from "../src/id.ts";
4+
5+
describe("ID", () => {
6+
test('unique', () => assertEquals(ID.unique(), 'unique()'));
7+
test('custom', () => assertEquals(ID.custom('custom'), 'custom'));
8+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
2+
import { describe, it as test } from "https://deno.land/[email protected]/testing/bdd.ts";
3+
import {Permission} from "../src/permission.ts";
4+
import {Role} from "../src/role.ts";
5+
6+
describe('Permission', () => {
7+
test('read', () => assertEquals(Permission.read(Role.any()), 'read("any")'));
8+
test('write', () => assertEquals(Permission.write(Role.any()), 'write("any")'));
9+
test('create', () => assertEquals(Permission.create(Role.any()), 'create("any")'));
10+
test('update', () => assertEquals(Permission.update(Role.any()), 'update("any")'));
11+
test('delete', () => assertEquals(Permission.delete(Role.any()), 'delete("any")'));
12+
})
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
import {describe, it as test} from "https://deno.land/[email protected]/testing/bdd.ts";
2+
import {assertEquals} from "https://deno.land/[email protected]/assert/assert_equals.ts";
3+
import {Query, QueryTypes} from "../src/query.ts";
4+
5+
type BasicFilterQueryTest = {
6+
description: string;
7+
value: QueryTypes;
8+
expectedValues: string;
9+
}
10+
11+
const tests: BasicFilterQueryTest[] = [
12+
{
13+
description: 'with a string',
14+
value: 's',
15+
expectedValues: '["s"]'
16+
},
17+
{
18+
description: 'with a integer',
19+
value: 1,
20+
expectedValues: '[1]'
21+
},
22+
{
23+
description: 'with a double',
24+
value: 1.2,
25+
expectedValues: '[1.2]'
26+
},
27+
{
28+
description: 'with a whole number double',
29+
value: 1.0,
30+
expectedValues: '[1]'
31+
},
32+
{
33+
description: 'with a bool',
34+
value: false,
35+
expectedValues: '[false]'
36+
},
37+
{
38+
description: 'with a list',
39+
value: ['a', 'b', 'c'],
40+
expectedValues: '["a","b","c"]'
41+
}
42+
];
43+
44+
describe('Query', () => {
45+
describe('basic filter equal', () => {
46+
for (const t of tests) {
47+
test(t.description, () =>
48+
assertEquals(
49+
Query.equal("attr", t.value),
50+
`equal("attr", ${t.expectedValues})`,
51+
)
52+
)
53+
}
54+
})
55+
56+
describe('basic filter notEqual', () => {
57+
for (const t of tests) {
58+
test(t.description, () =>
59+
assertEquals(
60+
Query.notEqual("attr", t.value),
61+
`notEqual("attr", ${t.expectedValues})`,
62+
)
63+
)
64+
}
65+
});
66+
67+
describe('basic filter lessThan', () => {
68+
for (const t of tests) {
69+
test(t.description, () =>
70+
assertEquals(
71+
Query.lessThan("attr", t.value),
72+
`lessThan("attr", ${t.expectedValues})`,
73+
)
74+
)
75+
}
76+
});
77+
78+
describe('basic filter lessThanEqual', () => {
79+
for (const t of tests) {
80+
test(t.description, () =>
81+
assertEquals(
82+
Query.lessThanEqual("attr", t.value),
83+
`lessThanEqual("attr", ${t.expectedValues})`,
84+
)
85+
)
86+
}
87+
});
88+
89+
describe('basic filter greaterThan', () => {
90+
for (const t of tests) {
91+
test(t.description, () =>
92+
assertEquals(
93+
Query.greaterThan("attr", t.value),
94+
`greaterThan("attr", ${t.expectedValues})`,
95+
)
96+
)
97+
}
98+
});
99+
100+
describe('basic filter greaterThanEqual', () => {
101+
for (const t of tests) {
102+
test(t.description, () =>
103+
assertEquals(
104+
Query.greaterThanEqual("attr", t.value),
105+
`greaterThanEqual("attr", ${t.expectedValues})`,
106+
)
107+
)
108+
}
109+
});
110+
111+
test('search', () => assertEquals(
112+
Query.search('attr', 'keyword1 keyword2'),
113+
'search("attr", ["keyword1 keyword2"])',
114+
));
115+
116+
test('isNull', () => assertEquals(
117+
Query.isNull('attr'),
118+
'isNull("attr")',
119+
));
120+
121+
test('isNotNull', () => assertEquals(
122+
Query.isNotNull('attr'),
123+
'isNotNull("attr")',
124+
));
125+
126+
describe('between', () => {
127+
test('with integers', () => assertEquals(
128+
Query.between('attr', 1, 2),
129+
'between("attr", 1, 2)'
130+
));
131+
test('with doubles', () => assertEquals(
132+
Query.between('attr', 1.2, 2.2),
133+
'between("attr", 1.2, 2.2)'
134+
));
135+
test('with strings', () => assertEquals(
136+
Query.between('attr', "a", "z"),
137+
'between("attr", "a", "z")'
138+
));
139+
});
140+
141+
test('select', () => assertEquals(
142+
Query.select(['attr1', 'attr2']),
143+
'select(["attr1","attr2"])',
144+
));
145+
146+
test('orderAsc', () => assertEquals(
147+
Query.orderAsc('attr'),
148+
'orderAsc("attr")',
149+
));
150+
151+
test('orderDesc', () => assertEquals(
152+
Query.orderDesc('attr'),
153+
'orderDesc("attr")',
154+
));
155+
156+
test('cursorBefore', () => assertEquals(
157+
Query.cursorBefore('attr'),
158+
'cursorBefore("attr")',
159+
));
160+
161+
test('cursorAfter', () => assertEquals(
162+
Query.cursorAfter('attr'),
163+
'cursorAfter("attr")',
164+
));
165+
166+
test('limit', () => assertEquals(
167+
Query.limit(1),
168+
'limit(1)'
169+
));
170+
171+
test('offset', () => assertEquals(
172+
Query.offset(1),
173+
'offset(1)'
174+
));
175+
})

templates/deno/test/role.test.ts.twig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { assertEquals } from "https://deno.land/[email protected]/assert/mod.ts";
2+
import { describe, it as test } from "https://deno.land/[email protected]/testing/bdd.ts";
3+
import {Role} from "../src/role.ts";
4+
5+
describe('Role', () => {
6+
test('any', () => assertEquals(Role.any(), 'any'));
7+
test('user without status', () => assertEquals(Role.user('custom'), 'user:custom'));
8+
test('user with status', () => assertEquals(Role.user('custom', 'verified'), 'user:custom/verified'));
9+
test('users without status', () => assertEquals(Role.users(), 'users'));
10+
test('users with status', () => assertEquals(Role.users('verified'), 'users/verified'));
11+
test('guests', () => assertEquals(Role.guests(), 'guests'));
12+
test('team without role', () => assertEquals(Role.team('custom'), 'team:custom'))
13+
test('team with role', () => assertEquals(Role.team('custom', 'owner'), 'team:custom/owner'))
14+
test('member', () => assertEquals(Role.member('custom'), 'member:custom'))
15+
test('label', () => assertEquals(Role.label('admin'), 'label:admin'))
16+
})

0 commit comments

Comments
 (0)