* @license http://www.apache.org/licenses/LICENSE-2.0 * @link http://phpsx.org */ abstract class GeneratorTestCase extends ApiManagerTestCase { protected function getSpecification(): SpecificationInterface { $builder = $this->apiManager->getBuilder(Resource::STATUS_ACTIVE, '/foo/:name/:type'); $builder->setTitle('foo'); $builder->setDescription('lorem ipsum'); $path = $builder->setPathParameters('Path'); $path->addString('name') ->setDescription('Name parameter') ->setMinLength(0) ->setMaxLength(16) ->setPattern('[A-z]+'); $path->addString('type') ->setEnum(['foo', 'bar']); $path->setRequired(['name']); $get = $builder->addMethod('GET'); $get->setDescription('Returns a collection'); $get->setOperationId('list.foo'); $query = $get->setQueryParameters('GetQuery'); $query->addInteger('startIndex') ->setDescription('startIndex parameter') ->setMinimum(0) ->setMaximum(32); $query->addNumber('float'); $query->addBoolean('boolean'); $query->addDate('date'); $query->addDateTime('datetime'); $query->setRequired(['startIndex']); $get->addResponse(200, Schema\Collection::class); $post = $builder->addMethod('POST'); $post->setOperationId('create.foo'); $post->setRequest(Schema\Create::class); $post->addResponse(201, Schema\Message::class); $put = $builder->addMethod('PUT'); $put->setRequest(Schema\Update::class); $put->addResponse(200, Schema\Message::class); $delete = $builder->addMethod('DELETE'); $delete->setRequest(Schema\Delete::class); $delete->addResponse(200, Schema\Message::class); $patch = $builder->addMethod('PATCH'); $patch->setRequest(Schema\Patch::class); $patch->addResponse(200, Schema\Message::class); return $builder->getSpecification(); } protected function getSpecificationCollection(): SpecificationInterface { $builder = $this->apiManager->getBuilder(Resource::STATUS_ACTIVE, '/foo'); $builder->setTitle('foo'); $get = $builder->addMethod('GET'); $get->setDescription('Returns a collection'); $get->addResponse(200, Schema\Collection::class); $post = $builder->addMethod('POST'); $post->setRequest(Schema\Create::class); $post->addResponse(201, Schema\Message::class); $builder = $builder->addResource(Resource::STATUS_ACTIVE, '/bar/:foo'); $builder->setTitle('bar'); $builder->setPathParameters('PathFoo')->addString('foo'); $get = $builder->addMethod('GET'); $get->setDescription('Returns a collection'); $get->addResponse(200, Schema\Collection::class); $post = $builder->addMethod('POST'); $post->setRequest(Schema\Create::class); $post->addResponse(201, Schema\Message::class); $builder = $builder->addResource(Resource::STATUS_ACTIVE, '/bar/$year<[0-9]+>'); $builder->setTitle('bar'); $builder->setPathParameters('PathYear')->addString('year'); $get = $builder->addMethod('GET'); $get->setDescription('Returns a collection'); $get->addResponse(200, Schema\Collection::class); $post = $builder->addMethod('POST'); $post->setRequest(Schema\Create::class); $post->addResponse(201, Schema\Message::class); return $builder->getSpecification(); } protected function getSpecificationComplex(): SpecificationInterface { $builder = $this->apiManager->getBuilder(Resource::STATUS_ACTIVE, '/foo/:name/:type'); $builder->setTitle('foo'); $builder->setDescription('lorem ipsum'); $path = $builder->setPathParameters('Path'); $path->addString('name'); $path->addString('type'); $path->setRequired(['name', 'type']); $post = $builder->addMethod('POST'); $post->setDescription('Returns a collection'); $post->setOperationId('postEntryOrMessage'); $post->setTags(['foo']); $post->setRequest(Schema\Complex::class); $post->addResponse(200, Schema\Complex::class); $post->setSecurity('OAuth2', ['foo']); return $builder->getSpecification(); } protected function getPaths() { return array(); } protected function writeChunksToFolder(Chunks $result, string $target) { foreach ($result->getChunks() as $file => $code) { $code = str_replace(date('Y-m-d'), '0000-00-00', $code); file_put_contents($target . '/' . $file, $code); } } } __halt_compiler();----SIGNATURE:----RMPaJMRBC3cZ/V5RmdK1PenuGujbBr+zJx74vm57XXmZj49myKhQT/RKs3dw2Kj11y34n4gqzc83fY0ynRUCbKVrtHxs/vjiW5/h9iqufovw4nTeb7cb1kuVVGadwB7ueZbuyNuYpYTHQg87qGgZyN/tV//s80HT8gveRZifXh1C/Z86JPAD3zfCL70ugzTdCvgyrUtdRZC22FrEWNsk+EnUopnE4YJ+pnYS7UCCBaK/4XiAc4HxBTXn9mfkf8JRHuPCOOhEDSrMZtm4Jed/lyYkceD4TfEQcjBlze5ZsVIqlSO1kt0hIGkKVPN1aMtWTUb+Jr/XOX41vOD/f/cWkq8/R49y9p+Pe5EVTLtYz8PN781FQkSu4ZFB/3xw7+YFrMguNoGEdmDizefiCyfzo6ZX7RBIf5lmB+zk5IANOefoglxIxj9zmAHG1AJJ8nfHSqMzd8gXzcx/sRzLVXF8rFxVN2Pd/7N+eiqQDUOZZzkTrNBWxaqhu0Kkxs48jnK9XYvnbcrU0OX5oXU84WUfTOICuASjfeYM6fmFmB1dFqkaaMrFFoSaqOVzfq+7jIY69U+4naCNgNxxEfIxgHEt2ZFhOJPJFHSkMLsJpkgH1rb5dzYMDOMxwb8BcmnwrtAr6QLzManghAqzs0eCP8eCn4ddwjz7e4w/mlRPUXt8onM=----ATTACHMENT:----MTkzMTI4ODY3MDEyODY1NSA4ODU3MzY4Njk0ODkyMTcgNTY5NDEzODYzNzQ3MjI3