Преглед изворни кода

Remove FormRequest parsing (#343)

shalvah пре 6 година
родитељ
комит
1ea162f3c9

+ 0 - 404
src/Mpociot/ApiDoc/Generators/AbstractGenerator.php

@@ -2,9 +2,7 @@
 
 namespace Mpociot\ApiDoc\Generators;
 
-use Faker\Factory;
 use ReflectionClass;
-use Illuminate\Support\Arr;
 use Illuminate\Support\Str;
 use League\Fractal\Manager;
 use Illuminate\Routing\Route;
@@ -12,10 +10,6 @@ use Mpociot\Reflection\DocBlock;
 use League\Fractal\Resource\Item;
 use Mpociot\Reflection\DocBlock\Tag;
 use League\Fractal\Resource\Collection;
-use Illuminate\Support\Facades\Validator;
-use Illuminate\Foundation\Http\FormRequest;
-use Mpociot\ApiDoc\Parsers\RuleDescriptionParser as Description;
-use Illuminate\Contracts\Validation\Factory as ValidationFactory;
 
 abstract class AbstractGenerator
 {
@@ -148,52 +142,9 @@ abstract class AbstractGenerator
      */
     protected function getParameters($routeData, $routeAction, $bindings)
     {
-        $validationRules = $this->getRouteValidationRules($routeData['methods'], $routeAction['uses'], $bindings);
-        $rules = $this->simplifyRules($validationRules);
-
-        foreach ($rules as $attribute => $ruleset) {
-            $attributeData = [
-                'required' => false,
-                'type' => null,
-                'default' => '',
-                'value' => '',
-                'description' => [],
-            ];
-            foreach ($ruleset as $rule) {
-                $this->parseRule($rule, $attribute, $attributeData, $routeData['id'], $routeData);
-            }
-            $routeData['parameters'][$attribute] = $attributeData;
-        }
-
         return $routeData;
     }
 
-    /**
-     * Format the validation rules as a plain array.
-     *
-     * @param array $rules
-     *
-     * @return array
-     */
-    protected function simplifyRules($rules)
-    {
-        // this will split all string rules into arrays of strings
-        $newRules = Validator::make([], $rules)->getRules();
-
-        // Laravel will ignore the nested array rules unless the key referenced exists and is an array
-        // So we'll create an empty array for each array attribute
-        $values = collect($newRules)
-            ->filter(function ($values) {
-                return in_array('array', $values);
-            })->map(function ($val, $key) {
-                return [str_random()];
-            })->all();
-
-        // Now this will return the complete ruleset.
-        // Nested array parameters will be present, with '*' replaced by '0'
-        return Validator::make($values, $rules)->getRules();
-    }
-
     /**
      * @param  $route
      * @param  $bindings
@@ -282,302 +233,6 @@ abstract class AbstractGenerator
         return 'general';
     }
 
-    /**
-     * @param  array $routeMethods
-     * @param  string $routeAction
-     * @param  array $bindings
-     *
-     * @return array
-     */
-    protected function getRouteValidationRules(array $routeMethods, $routeAction, $bindings)
-    {
-        list($controller, $method) = explode('@', $routeAction);
-        $reflection = new ReflectionClass($controller);
-        $reflectionMethod = $reflection->getMethod($method);
-
-        foreach ($reflectionMethod->getParameters() as $parameter) {
-            $parameterType = $parameter->getClass();
-            if (! is_null($parameterType) && class_exists($parameterType->name)) {
-                $className = $parameterType->name;
-
-                if (is_subclass_of($className, FormRequest::class)) {
-                    /** @var FormRequest $formRequest */
-                    $formRequest = new $className;
-                    // Add route parameter bindings
-                    $formRequest->setContainer(app());
-                    $formRequest->request->add($bindings);
-                    $formRequest->query->add($bindings);
-                    $formRequest->setMethod($routeMethods[0]);
-
-                    if (method_exists($formRequest, 'validator')) {
-                        $factory = app(ValidationFactory::class);
-
-                        return call_user_func_array([$formRequest, 'validator'], [$factory])
-                            ->getRules();
-                    } else {
-                        return call_user_func_array([$formRequest, 'rules'], []);
-                    }
-                }
-            }
-        }
-
-        return [];
-    }
-
-    /**
-     * @param  array  $arr
-     * @param  string  $first
-     * @param  string  $last
-     *
-     * @return string
-     */
-    protected function fancyImplode($arr, $first, $last)
-    {
-        $arr = array_map(function ($value) {
-            return '`'.$value.'`';
-        }, $arr);
-        array_push($arr, implode($last, array_splice($arr, -2)));
-
-        return implode($first, $arr);
-    }
-
-    protected function splitValuePairs($parameters, $first = 'is ', $last = 'or ')
-    {
-        $attribute = '';
-        collect($parameters)->map(function ($item, $key) use (&$attribute, $first, $last) {
-            $attribute .= '`'.$item.'` ';
-            if (($key + 1) % 2 === 0) {
-                $attribute .= $last;
-            } else {
-                $attribute .= $first;
-            }
-        });
-        $attribute = rtrim($attribute, $last);
-
-        return $attribute;
-    }
-
-    /**
-     * @param  string  $rule
-     * @param  string  $attribute
-     * @param  array  $attributeData
-     * @param  int  $seed
-     *
-     * @return void
-     */
-    protected function parseRule($rule, $attribute, &$attributeData, $seed, $routeData)
-    {
-        if (starts_with($attribute, 'array.')) { dd(array_keys($routeData)); }
-        $faker = Factory::create();
-        $faker->seed(crc32($seed));
-
-        $parsedRule = $this->parseStringRule($rule);
-        $parsedRule[0] = $this->normalizeRule($parsedRule[0]);
-        list($rule, $parameters) = $parsedRule;
-
-        switch ($rule) {
-            case 'required':
-                $attributeData['required'] = true;
-                break;
-            case 'accepted':
-                $attributeData['required'] = true;
-                $attributeData['type'] = 'boolean';
-                $attributeData['value'] = true;
-                break;
-            case 'after':
-                $attributeData['type'] = 'date';
-                $format = isset($attributeData['format']) ? $attributeData['format'] : DATE_RFC850;
-
-                if (strtotime($parameters[0]) === false) {
-                    // the `after` date refers to another parameter in the request
-                    $paramName = $parameters[0];
-                    $attributeData['description'][] = Description::parse($rule)->with($paramName)->getDescription();
-                    $attributeData['value'] = date($format, strtotime('+1 day', strtotime($routeData['parameters'][$paramName]['value'])));
-                } else {
-                    $attributeData['description'][] = Description::parse($rule)->with(date($format, strtotime($parameters[0])))->getDescription();
-                    $attributeData['value'] = date($format, strtotime('+1 day', strtotime($parameters[0])));
-                }
-                break;
-            case 'alpha':
-                $attributeData['description'][] = Description::parse($rule)->getDescription();
-                $attributeData['value'] = $faker->word;
-                break;
-            case 'alpha_dash':
-                $attributeData['description'][] = Description::parse($rule)->getDescription();
-                break;
-            case 'alpha_num':
-                $attributeData['description'][] = Description::parse($rule)->getDescription();
-                break;
-            case 'in':
-                $attributeData['description'][] = Description::parse($rule)->with($this->fancyImplode($parameters, ', ', ' or '))->getDescription();
-                $attributeData['value'] = $faker->randomElement($parameters);
-                break;
-            case 'not_in':
-                $attributeData['description'][] = Description::parse($rule)->with($this->fancyImplode($parameters, ', ', ' or '))->getDescription();
-                $attributeData['value'] = $faker->word;
-                break;
-            case 'min':
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                if (Arr::get($attributeData, 'type') === 'numeric' || Arr::get($attributeData, 'type') === 'integer') {
-                    $attributeData['value'] = $faker->numberBetween($parameters[0]);
-                }
-                break;
-            case 'max':
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                if (Arr::get($attributeData, 'type') === 'numeric' || Arr::get($attributeData, 'type') === 'integer') {
-                    $attributeData['value'] = $faker->numberBetween(0, $parameters[0]);
-                }
-                break;
-            case 'between':
-                if (! isset($attributeData['type'])) {
-                    $attributeData['type'] = 'numeric';
-                }
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                $attributeData['value'] = $faker->numberBetween($parameters[0], $parameters[1]);
-                break;
-            case 'before':
-                $attributeData['type'] = 'date';
-                $format = isset($attributeData['format']) ? $attributeData['format'] : DATE_RFC850;
-
-                if (strtotime($parameters[0]) === false) {
-                    // the `before` date refers to another parameter in the request
-                    $paramName = $parameters[0];
-                    $attributeData['description'][] = Description::parse($rule)->with($paramName)->getDescription();
-                    $attributeData['value'] = date($format, strtotime('-1 day', strtotime($routeData['parameters'][$paramName]['value'])));
-                } else {
-                    $attributeData['description'][] = Description::parse($rule)->with(date($format, strtotime($parameters[0])))->getDescription();
-                    $attributeData['value'] = date($format, strtotime('-1 day', strtotime($parameters[0])));
-                }
-                break;
-            case 'date_format':
-                $attributeData['type'] = 'date';
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                $attributeData['format'] = $parameters[0];
-                $attributeData['value'] = date($attributeData['format']);
-                break;
-            case 'different':
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                break;
-            case 'digits':
-                $attributeData['type'] = 'numeric';
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                $attributeData['value'] = ($parameters[0] < 9) ? $faker->randomNumber($parameters[0], true) : substr(mt_rand(100000000, mt_getrandmax()), 0, $parameters[0]);
-                break;
-            case 'digits_between':
-                $attributeData['type'] = 'numeric';
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                break;
-            case 'file':
-                $attributeData['type'] = 'file';
-                $attributeData['description'][] = Description::parse($rule)->getDescription();
-                break;
-            case 'image':
-                $attributeData['type'] = 'image';
-                $attributeData['description'][] = Description::parse($rule)->getDescription();
-                break;
-            case 'json':
-                $attributeData['type'] = 'string';
-                $attributeData['description'][] = Description::parse($rule)->getDescription();
-                $attributeData['value'] = json_encode(['foo', 'bar', 'baz']);
-                break;
-            case 'mimetypes':
-            case 'mimes':
-                $attributeData['description'][] = Description::parse($rule)->with($this->fancyImplode($parameters, ', ', ' or '))->getDescription();
-                break;
-            case 'required_if':
-                $attributeData['description'][] = Description::parse($rule)->with($this->splitValuePairs($parameters))->getDescription();
-                break;
-            case 'required_unless':
-                $attributeData['description'][] = Description::parse($rule)->with($this->splitValuePairs($parameters))->getDescription();
-                break;
-            case 'required_with':
-                $attributeData['description'][] = Description::parse($rule)->with($this->fancyImplode($parameters, ', ', ' or '))->getDescription();
-                break;
-            case 'required_with_all':
-                $attributeData['description'][] = Description::parse($rule)->with($this->fancyImplode($parameters, ', ', ' and '))->getDescription();
-                break;
-            case 'required_without':
-                $attributeData['description'][] = Description::parse($rule)->with($this->fancyImplode($parameters, ', ', ' or '))->getDescription();
-                break;
-            case 'required_without_all':
-                $attributeData['description'][] = Description::parse($rule)->with($this->fancyImplode($parameters, ', ', ' and '))->getDescription();
-                break;
-            case 'same':
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                break;
-            case 'size':
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                break;
-            case 'timezone':
-                $attributeData['description'][] = Description::parse($rule)->getDescription();
-                $attributeData['value'] = $faker->timezone;
-                break;
-            case 'exists':
-                $fieldName = isset($parameters[1]) ? $parameters[1] : $attribute;
-                $attributeData['description'][] = Description::parse($rule)->with([Str::singular($parameters[0]), $fieldName])->getDescription();
-                break;
-            case 'active_url':
-                $attributeData['type'] = 'url';
-                $attributeData['value'] = $faker->url;
-                break;
-            case 'regex':
-                $attributeData['type'] = 'string';
-                $attributeData['description'][] = Description::parse($rule)->with($parameters)->getDescription();
-                break;
-            case 'boolean':
-                $attributeData['value'] = true;
-                $attributeData['type'] = $rule;
-                break;
-            case 'array':
-                $attributeData['value'] = [$faker->word];
-                $attributeData['type'] = $rule;
-                $attributeData['description'][] = Description::parse($rule)->getDescription();
-                break;
-            case 'date':
-                $attributeData['value'] = $faker->date();
-                $attributeData['type'] = $rule;
-                break;
-            case 'email':
-                $attributeData['value'] = $faker->safeEmail;
-                $attributeData['type'] = $rule;
-                break;
-            case 'string':
-                $attributeData['value'] = $faker->word;
-                $attributeData['type'] = $rule;
-                break;
-            case 'integer':
-                $attributeData['value'] = $faker->randomNumber();
-                $attributeData['type'] = $rule;
-                break;
-            case 'numeric':
-                $attributeData['value'] = $faker->randomNumber();
-                $attributeData['type'] = $rule;
-                break;
-            case 'url':
-                $attributeData['value'] = $faker->url;
-                $attributeData['type'] = $rule;
-                break;
-            case 'ip':
-                $attributeData['value'] = $faker->ipv4;
-                $attributeData['type'] = $rule;
-                break;
-            default:
-                $unknownRuleDescription = Description::parse($rule)->getDescription();
-                if ($unknownRuleDescription) {
-                    $attributeData['description'][] = $unknownRuleDescription;
-                }
-                break;
-        }
-
-        if ($attributeData['value'] === '') {
-            $attributeData['value'] = $faker->word;
-        }
-
-        if (is_null($attributeData['type'])) {
-            $attributeData['type'] = 'string';
-        }
-    }
-
     /**
      * Call the given URI and return the Response.
      *
@@ -618,65 +273,6 @@ abstract class AbstractGenerator
         return $server;
     }
 
-    /**
-     * Parse a string based rule.
-     *
-     * @param  string  $rules
-     *
-     * @return array
-     */
-    protected function parseStringRule($rules)
-    {
-        $parameters = [];
-
-        // The format for specifying validation rules and parameters follows an
-        // easy {rule}:{parameters} formatting convention. For instance the
-        // rule "max:3" states that the value may only be three letters.
-        if (strpos($rules, ':') !== false) {
-            list($rules, $parameter) = explode(':', $rules, 2);
-
-            $parameters = $this->parseParameters($rules, $parameter);
-        }
-
-        return [strtolower(trim($rules)), $parameters];
-    }
-
-    /**
-     * Parse a parameter list.
-     *
-     * @param  string  $rule
-     * @param  string  $parameter
-     *
-     * @return array
-     */
-    protected function parseParameters($rule, $parameter)
-    {
-        if (strtolower($rule) === 'regex') {
-            return [$parameter];
-        }
-
-        return str_getcsv($parameter);
-    }
-
-    /**
-     * Normalizes a rule so that we can accept short types.
-     *
-     * @param  string $rule
-     *
-     * @return string
-     */
-    protected function normalizeRule($rule)
-    {
-        switch ($rule) {
-            case 'int':
-                return 'integer';
-            case 'bool':
-                return 'boolean';
-            default:
-                return $rule;
-        }
-    }
-
     /**
      * @param $response
      *

+ 0 - 86
src/Mpociot/ApiDoc/Parsers/RuleDescriptionParser.php

@@ -1,86 +0,0 @@
-<?php
-
-namespace Mpociot\ApiDoc\Parsers;
-
-class RuleDescriptionParser
-{
-    private $rule;
-
-    private $parameters = [];
-
-    const DEFAULT_LOCALE = 'en';
-
-    /**
-     * @param null $rule
-     */
-    public function __construct($rule = null)
-    {
-        $this->rule = "apidoc::rules.{$rule}";
-    }
-
-    /**
-     * @return array|string
-     */
-    public function getDescription()
-    {
-        return $this->ruleDescriptionExist() ? $this->makeDescription() : [];
-    }
-
-    /**
-     * @param string|array $parameters
-     *
-     * @return $this
-     */
-    public function with($parameters)
-    {
-        is_array($parameters) ?
-            $this->parameters += $parameters :
-            $this->parameters[] = $parameters;
-
-        return $this;
-    }
-
-    /**
-     * @return bool
-     */
-    protected function ruleDescriptionExist()
-    {
-        return trans()->hasForLocale($this->rule) || trans()->hasForLocale($this->rule, self::DEFAULT_LOCALE);
-    }
-
-    /**
-     * @return string
-     */
-    protected function makeDescription()
-    {
-        $description = trans()->hasForLocale($this->rule) ?
-                            trans()->get($this->rule) :
-                            trans()->get($this->rule, [], self::DEFAULT_LOCALE);
-
-        return $this->replaceAttributes($description);
-    }
-
-    /**
-     * @param string $description$
-     *
-     * @return string
-     */
-    protected function replaceAttributes($description)
-    {
-        foreach ($this->parameters as $parameter) {
-            $description = preg_replace('/:attribute/', $parameter, $description, 1);
-        }
-
-        return $description;
-    }
-
-    /**
-     * @param null $rule
-     *
-     * @return static
-     */
-    public static function parse($rule = null)
-    {
-        return new static($rule);
-    }
-}

+ 0 - 35
src/resources/lang/en/rules.php

@@ -1,35 +0,0 @@
-<?php
-
-return [
-    'after' => 'Must be a date after: `:attribute`',
-    'alpha' => 'Only alphabetic characters allowed',
-    'alpha_dash' => 'Allowed: alpha-numeric characters, as well as dashes and underscores.',
-    'alpha_num' => 'Only alpha-numeric characters allowed',
-    'array' => 'Must be an array',
-    'in' => ':attribute',
-    'not_in' => 'Not in: :attribute',
-    'min' => 'Minimum: `:attribute`',
-    'max' => 'Maximum: `:attribute`',
-    'between' => 'Between: `:attribute` and `:attribute`',
-    'before' => 'Must be a date preceding: `:attribute`',
-    'date_format' => 'Date format: `:attribute`',
-    'different' => 'Must have a different value than parameter: `:attribute`',
-    'digits' => 'Must have an exact length of `:attribute`',
-    'digits_between' => 'Must have a length between `:attribute` and `:attribute`',
-    'file' => 'Must be a file upload',
-    'image' => 'Must be an image (jpeg, png, bmp, gif, or svg)',
-    'json' => 'Must be a valid JSON string.',
-    'mimetypes' => 'Allowed mime types: :attribute',
-    'mimes' => 'Allowed mime types: :attribute',
-    'required_if' => 'Required if :attribute',
-    'required_unless' => 'Required unless :attribute',
-    'required_with' => 'Required if the parameters :attribute are present.',
-    'required_with_all' => 'Required if the parameters :attribute are present.',
-    'required_without' => 'Required if the parameters :attribute are not present.',
-    'required_without_all' => 'Required if the parameters :attribute are not present.',
-    'same' => 'Must be the same as `:attribute`',
-    'size' => 'Must have the size of `:attribute`',
-    'timezone' => 'Must be a valid timezone identifier',
-    'exists' => 'Valid :attribute :attribute',
-    'regex' => 'Must match this regular expression: `:attribute`',
-];

+ 0 - 272
tests/ApiDocGeneratorTest.php

@@ -4,7 +4,6 @@ namespace Mpociot\ApiDoc\Tests;
 
 use Illuminate\Routing\Route;
 use Orchestra\Testbench\TestCase;
-use Mpociot\ApiDoc\Tests\Fixtures\TestRequest;
 use Mpociot\ApiDoc\Generators\LaravelGenerator;
 use Mpociot\ApiDoc\Tests\Fixtures\TestController;
 use Mpociot\ApiDoc\ApiDocGeneratorServiceProvider;
@@ -76,277 +75,6 @@ class ApiDocGeneratorTest extends TestCase
         $this->assertTrue(is_array($parsed));
     }
 
-    public function testCanParseFormRequestRules()
-    {
-        RouteFacade::post('/post', TestController::class.'@parseFormRequestRules');
-        $route = new Route(['POST'], '/post', ['uses' => TestController::class.'@parseFormRequestRules']);
-        $parsed = $this->generator->processRoute($route);
-        $parameters = $parsed['parameters'];
-
-        $testRequest = new TestRequest();
-        $rules = $testRequest->rules();
-
-        foreach ($rules as $name => $rule) {
-            $attribute = $parameters[$name];
-
-            switch ($name) {
-
-                case 'required':
-                    $this->assertTrue($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'accepted':
-                    $this->assertTrue($attribute['required']);
-                    $this->assertSame('boolean', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'active_url':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('url', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'alpha':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Only alphabetic characters allowed', $attribute['description'][0]);
-                    break;
-                case 'alpha_dash':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Allowed: alpha-numeric characters, as well as dashes and underscores.', $attribute['description'][0]);
-                    break;
-                case 'alpha_num':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Only alpha-numeric characters allowed', $attribute['description'][0]);
-                    break;
-                case 'array':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('array', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    break;
-                case 'between':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('numeric', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Between: `5` and `200`', $attribute['description'][0]);
-                    break;
-                case 'string_between':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Between: `5` and `200`', $attribute['description'][0]);
-                    break;
-                case 'before':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('date', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be a date preceding: `Saturday, 23-Apr-16 14:31:00 UTC`', $attribute['description'][0]);
-                    break;
-                case 'boolean':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('boolean', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'date':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('date', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'date_format':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('date', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Date format: `j.n.Y H:iP`', $attribute['description'][0]);
-                    break;
-                case 'different':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must have a different value than parameter: `alpha_num`', $attribute['description'][0]);
-                    break;
-                case 'digits':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('numeric', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must have an exact length of `2`', $attribute['description'][0]);
-                    break;
-                case 'digits_between':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('numeric', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must have a length between `2` and `10`', $attribute['description'][0]);
-                    break;
-                case 'email':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('email', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'exists':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Valid user firstname', $attribute['description'][0]);
-                    break;
-                case 'single_exists':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Valid user single_exists', $attribute['description'][0]);
-                    break;
-                case 'file':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('file', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be a file upload', $attribute['description'][0]);
-                    break;
-                case 'image':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('image', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be an image (jpeg, png, bmp, gif, or svg)', $attribute['description'][0]);
-                    break;
-                case 'in':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('`jpeg`, `png`, `bmp`, `gif` or `svg`', $attribute['description'][0]);
-                    break;
-                case 'integer':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('integer', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'ip':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('ip', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'json':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be a valid JSON string.', $attribute['description'][0]);
-                    break;
-                case 'max':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Maximum: `10`', $attribute['description'][0]);
-                    break;
-                case 'min':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Minimum: `20`', $attribute['description'][0]);
-                    break;
-                case 'mimes':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Allowed mime types: `jpeg`, `bmp` or `png`', $attribute['description'][0]);
-                    break;
-                case 'not_in':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Not in: `foo` or `bar`', $attribute['description'][0]);
-                    break;
-                case 'numeric':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('numeric', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'regex':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must match this regular expression: `(.*)`', $attribute['description'][0]);
-                    break;
-                case 'multiple_required_if':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if `foo` is `bar` or `baz` is `qux`', $attribute['description'][0]);
-                    break;
-                case 'required_if':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if `foo` is `bar`', $attribute['description'][0]);
-                    break;
-                case 'required_unless':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required unless `foo` is `bar`', $attribute['description'][0]);
-                    break;
-                case 'required_with':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if the parameters `foo`, `bar` or `baz` are present.', $attribute['description'][0]);
-                    break;
-                case 'required_with_all':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if the parameters `foo`, `bar` and `baz` are present.', $attribute['description'][0]);
-                    break;
-                case 'required_without':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if the parameters `foo`, `bar` or `baz` are not present.', $attribute['description'][0]);
-                    break;
-                case 'required_without_all':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if the parameters `foo`, `bar` and `baz` are not present.', $attribute['description'][0]);
-                    break;
-                case 'same':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be the same as `foo`', $attribute['description'][0]);
-                    break;
-                case 'size':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must have the size of `51`', $attribute['description'][0]);
-                    break;
-                case 'timezone':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be a valid timezone identifier', $attribute['description'][0]);
-                    break;
-                case 'url':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('url', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-
-            }
-        }
-    }
-
-    public function testCustomFormRequestValidatorIsSupported()
-    {
-        RouteFacade::post('/post', TestController::class.'@customFormRequestValidator');
-        $route = new Route(['POST'], '/post', ['uses' => TestController::class.'@customFormRequestValidator']);
-        $parsed = $this->generator->processRoute($route);
-        $parameters = $parsed['parameters'];
-
-        $this->assertNotEmpty($parameters);
-    }
-
     public function testCanParseResponseTag()
     {
         RouteFacade::post('/responseTag', TestController::class.'@responseTag');

+ 0 - 276
tests/DingoGeneratorTest.php

@@ -37,10 +37,6 @@ class DingoGeneratorTest extends TestCase
 
     public function testCanParseMethodDescription()
     {
-        if (version_compare($this->app->version(), '5.4', '>=')) {
-            $this->markTestSkipped('Dingo does not support Laravel 5.4');
-        }
-
         $api = app('Dingo\Api\Routing\Router');
         $api->version('v1', function ($api) {
             $api->get('/api/test', TestController::class.'@parseMethodDescription');
@@ -55,10 +51,6 @@ class DingoGeneratorTest extends TestCase
 
     public function testCanParseRouteMethods()
     {
-        if (version_compare($this->app->version(), '5.4', '>=')) {
-            $this->markTestSkipped('Dingo does not support Laravel 5.4');
-        }
-
         $api = app('Dingo\Api\Routing\Router');
         $api->version('v1', function ($api) {
             $api->get('/get', TestController::class.'@dummy');
@@ -83,272 +75,4 @@ class DingoGeneratorTest extends TestCase
         $this->assertSame(['DELETE'], $parsed['methods']);
     }
 
-    public function testCanParseFormRequestRules()
-    {
-        if (version_compare($this->app->version(), '5.4', '>=')) {
-            $this->markTestSkipped('Dingo does not support Laravel 5.4');
-        }
-
-        $api = app('Dingo\Api\Routing\Router');
-        $api->version('v1', function ($api) {
-            $api->post('/post', DingoTestController::class.'@parseFormRequestRules');
-        });
-
-        $route = app('Dingo\Api\Routing\Router')->getRoutes()['v1']->getRoutes()[0];
-        $parsed = $this->generator->processRoute($route);
-        $parameters = $parsed['parameters'];
-
-        $testRequest = new TestRequest();
-        $rules = $testRequest->rules();
-
-        foreach ($rules as $name => $rule) {
-            $attribute = $parameters[$name];
-
-            switch ($name) {
-
-                case 'required':
-                    $this->assertTrue($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'accepted':
-                    $this->assertTrue($attribute['required']);
-                    $this->assertSame('boolean', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'active_url':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('url', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'alpha':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Only alphabetic characters allowed', $attribute['description'][0]);
-                    break;
-                case 'alpha_dash':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Allowed: alpha-numeric characters, as well as dashes and underscores.', $attribute['description'][0]);
-                    break;
-                case 'alpha_num':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Only alpha-numeric characters allowed', $attribute['description'][0]);
-                    break;
-                case 'array':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('array', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'between':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('numeric', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Between: `5` and `200`', $attribute['description'][0]);
-                    break;
-                case 'string_between':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Between: `5` and `200`', $attribute['description'][0]);
-                    break;
-                case 'before':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('date', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be a date preceding: `Saturday, 23-Apr-16 14:31:00 UTC`', $attribute['description'][0]);
-                    break;
-                case 'boolean':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('boolean', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'date':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('date', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'date_format':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('date', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Date format: `j.n.Y H:iP`', $attribute['description'][0]);
-                    break;
-                case 'different':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must have a different value than parameter: `alpha_num`', $attribute['description'][0]);
-                    break;
-                case 'digits':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('numeric', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must have an exact length of `2`', $attribute['description'][0]);
-                    break;
-                case 'digits_between':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('numeric', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must have a length between `2` and `10`', $attribute['description'][0]);
-                    break;
-                case 'email':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('email', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'exists':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Valid user firstname', $attribute['description'][0]);
-                    break;
-                case 'single_exists':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Valid user single_exists', $attribute['description'][0]);
-                    break;
-                case 'file':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('file', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be a file upload', $attribute['description'][0]);
-                    break;
-                case 'image':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('image', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be an image (jpeg, png, bmp, gif, or svg)', $attribute['description'][0]);
-                    break;
-                case 'in':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('`jpeg`, `png`, `bmp`, `gif` or `svg`', $attribute['description'][0]);
-                    break;
-                case 'integer':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('integer', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'ip':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('ip', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'json':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be a valid JSON string.', $attribute['description'][0]);
-                    break;
-                case 'max':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Maximum: `10`', $attribute['description'][0]);
-                    break;
-                case 'min':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Minimum: `20`', $attribute['description'][0]);
-                    break;
-                case 'mimes':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Allowed mime types: `jpeg`, `bmp` or `png`', $attribute['description'][0]);
-                    break;
-                case 'not_in':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Not in: `foo` or `bar`', $attribute['description'][0]);
-                    break;
-                case 'numeric':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('numeric', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-                case 'regex':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must match this regular expression: `(.*)`', $attribute['description'][0]);
-                    break;
-                case 'multiple_required_if':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if `foo` is `bar` or `baz` is `qux`', $attribute['description'][0]);
-                    break;
-                case 'required_if':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if `foo` is `bar`', $attribute['description'][0]);
-                    break;
-                case 'required_unless':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required unless `foo` is `bar`', $attribute['description'][0]);
-                    break;
-                case 'required_with':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if the parameters `foo`, `bar` or `baz` are present.', $attribute['description'][0]);
-                    break;
-                case 'required_with_all':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if the parameters `foo`, `bar` and `baz` are present.', $attribute['description'][0]);
-                    break;
-                case 'required_without':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if the parameters `foo`, `bar` or `baz` are not present.', $attribute['description'][0]);
-                    break;
-                case 'required_without_all':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Required if the parameters `foo`, `bar` and `baz` are not present.', $attribute['description'][0]);
-                    break;
-                case 'same':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be the same as `foo`', $attribute['description'][0]);
-                    break;
-                case 'size':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must have the size of `51`', $attribute['description'][0]);
-                    break;
-                case 'timezone':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('string', $attribute['type']);
-                    $this->assertCount(1, $attribute['description']);
-                    $this->assertSame('Must be a valid timezone identifier', $attribute['description'][0]);
-                    break;
-                case 'url':
-                    $this->assertFalse($attribute['required']);
-                    $this->assertSame('url', $attribute['type']);
-                    $this->assertCount(0, $attribute['description']);
-                    break;
-
-            }
-        }
-    }
 }

+ 0 - 118
tests/RuleDescriptionParserTest.php

@@ -1,118 +0,0 @@
-<?php
-
-namespace Mpociot\ApiDoc\Tests;
-
-use Mockery as m;
-use Orchestra\Testbench\TestCase;
-use Illuminate\Translation\Translator;
-use Illuminate\Translation\LoaderInterface;
-use Mpociot\ApiDoc\Parsers\RuleDescriptionParser;
-use Mpociot\ApiDoc\ApiDocGeneratorServiceProvider;
-
-class RuleDescriptionParserTest extends TestCase
-{
-    protected $translatorMock;
-
-    public function setUp()
-    {
-        parent::setUp();
-        $fileLoaderMock = m::mock(LoaderInterface::class);
-        $this->translatorMock = m::mock(Translator::class, [$fileLoaderMock, 'es']);
-        $this->app->instance('translator', $this->translatorMock);
-    }
-
-    public function tearDown()
-    {
-        m::close();
-    }
-
-    public function testReturnsAnEmptyDescriptionIfARuleIsNotParsed()
-    {
-        $this->translatorMock->shouldReceive('hasForLocale')->twice()->andReturn(false);
-
-        $description = new RuleDescriptionParser();
-
-        $this->assertEmpty($description->getDescription());
-    }
-
-    public function testProvidesANamedContructor()
-    {
-        $this->assertInstanceOf(RuleDescriptionParser::class, RuleDescriptionParser::parse());
-    }
-
-    public function testReturnsADescriptionInMainLanguageIfAvailable()
-    {
-        $this->translatorMock->shouldReceive('hasForLocale')->twice()->with('apidoc::rules.alpha')->andReturn(true);
-        $this->translatorMock->shouldReceive('get')->once()->with('apidoc::rules.alpha')->andReturn('Solo caracteres alfabeticos permitidos');
-
-        $description = RuleDescriptionParser::parse('alpha')->getDescription();
-
-        $this->assertEquals('Solo caracteres alfabeticos permitidos', $description);
-    }
-
-    public function testReturnsDescriptionInDefaultLanguageIfNotAvailableInMainLanguage()
-    {
-        $this->translatorMock->shouldReceive('hasForLocale')->twice()->with('apidoc::rules.alpha')->andReturn(false);
-        $this->translatorMock->shouldReceive('hasForLocale')->once()->with('apidoc::rules.alpha', 'en')->andReturn(true);
-        $this->translatorMock->shouldReceive('get')->once()->with('apidoc::rules.alpha', [], 'en')->andReturn('Only alphabetic characters allowed');
-
-        $description = RuleDescriptionParser::parse('alpha')->getDescription();
-
-        $this->assertEquals('Only alphabetic characters allowed', $description);
-    }
-
-    public function testReturnsAnEmptyDescriptionIfNotAvailable()
-    {
-        $this->translatorMock->shouldReceive('hasForLocale')->once()->with('apidoc::rules.dummy_rule')->andReturn(false);
-        $this->translatorMock->shouldReceive('hasForLocale')->once()->with('apidoc::rules.dummy_rule', 'en')->andReturn(false);
-
-        $description = RuleDescriptionParser::parse('dummy_rule')->getDescription();
-
-        $this->assertEmpty($description);
-    }
-
-    public function testAllowsToPassParametersToTheDescription()
-    {
-        $this->translatorMock->shouldReceive('hasForLocale')->twice()->with('apidoc::rules.digits')->andReturn(false);
-        $this->translatorMock->shouldReceive('hasForLocale')->once()->with('apidoc::rules.digits', 'en')->andReturn(true);
-        $this->translatorMock->shouldReceive('get')->once()->with('apidoc::rules.digits', [], 'en')->andReturn('Must have an exact length of `:attribute`');
-
-        $description = RuleDescriptionParser::parse('digits')->with(2)->getDescription();
-
-        $this->assertEquals('Must have an exact length of `2`', $description);
-    }
-
-    public function testAllowsToPassMultipleParametersToTheDescription()
-    {
-        $this->translatorMock->shouldReceive('hasForLocale')->twice()->with('apidoc::rules.required_if')->andReturn(false);
-        $this->translatorMock->shouldReceive('hasForLocale')->once()->with('apidoc::rules.required_if', 'en')->andReturn(true);
-        $this->translatorMock->shouldReceive('get')->once()->with('apidoc::rules.required_if', [], 'en')->andReturn('Required if `:attribute` is `:attribute`');
-
-        $description = RuleDescriptionParser::parse('required_if')->with(['2 + 2', 4])->getDescription();
-
-        $this->assertEquals('Required if `2 + 2` is `4`', $description);
-    }
-
-    /**
-     * @param \Illuminate\Foundation\Application $app
-     *
-     * @return array
-     */
-    protected function getPackageProviders($app)
-    {
-        return [ApiDocGeneratorServiceProvider::class];
-    }
-
-    /**
-     * Define environment setup.
-     *
-     * @param  \Illuminate\Foundation\Application   $app
-     *
-     * @return void
-     */
-    protected function getEnvironmentSetUp($app)
-    {
-        $app['config']->set('app.locale', 'es'); // Just to be different from default language.
-        $app['config']->set('app.fallback_locale', 'ch'); // Just to be different from default language.
-    }
-}