Since: 5.6.14 (03.12.2015)
Author: Andrii Penchuk (a.penchuk@scalr.com)
Beispiel #1
0
 /**
  * Check readOnly vs required Object properties
  *
  * @test
  * @dataProvider specksProvider
  *
  * @param string $version api version
  * @param string $provider specifications type
  */
 public function testSpecks($version, $provider)
 {
     $specs = new SpecManager($version, $provider);
     $definitions = $specs->getDefinitions('#^Api.*|Response$#');
     $this->assertNotEmpty($definitions);
     /* @var  $definition ObjectEntity */
     foreach ($definitions as $name => $definition) {
         $intersectProp = array_intersect($definition->required, $definition->readOnly);
         $this->assertEmpty($intersectProp, sprintf('The property %s is mutually exclusive. should be required or read-only. Object %s in %s spec', implode(', ', $intersectProp), $name, $provider));
         //discriminator must be in the required property list
         if (!empty($definition->discriminator)) {
             $this->assertTrue(in_array($definition->discriminator, $definition->required), sprintf('Property discriminator must be required Object %s in %s spec', $name, $provider));
         }
     }
 }
Beispiel #2
0
 /**
  * Data provider for testGetEndpoint()
  *
  * @return array[]
  */
 public function dataGetEndpointProvider()
 {
     $basePaths = static::$userSpec->getPathTemplates(Request::METHOD_GET);
     $farmRoles = array_filter($basePaths, function ($v) {
         return preg_match('#^/{envId}/farm-roles#', $v);
     });
     foreach ($farmRoles as $i => $farmRole) {
         unset($basePaths[$i]);
     }
     array_push($basePaths, ...$farmRoles);
     $data = [];
     foreach ($basePaths as $basePath) {
         $data[$basePath] = [$basePath, 'user'];
     }
     $basePaths = static::$accountSpec->getPathTemplates(Request::METHOD_GET);
     foreach ($basePaths as $basePath) {
         $data[$basePath] = [$basePath, 'account'];
     }
     if (file_exists($ignoreFile = $this->getFixturesDirectory() . '/ignorePath.yaml')) {
         $ignorePaths = yaml_parse_file($ignoreFile);
         if (!empty($ignorePaths = $ignorePaths['paths'])) {
             $data = array_filter($data, function ($k) use($ignorePaths) {
                 foreach ($ignorePaths as $path) {
                     if (preg_match("#{$path}#", $k)) {
                         return false;
                     }
                 }
                 return true;
             }, ARRAY_FILTER_USE_KEY);
         }
     }
     return $data;
 }
Beispiel #3
0
 /**
  *  Data provider for testGetEndpoint()
  *
  * @return array[]
  */
 public function dataBaseGetEndpointProvider()
 {
     $basePaths = $this->userSpec->getPathTemplates(Request::METHOD_GET);
     $farmRoles = array_filter($basePaths, function ($v) {
         return preg_match('#^/{envId}/farm-roles#', $v);
     });
     foreach ($farmRoles as $i => $farmRole) {
         unset($basePaths[$i]);
     }
     array_push($basePaths, ...$farmRoles);
     $data = [];
     foreach ($basePaths as $basePath) {
         $data[$basePath] = [$basePath, 'user'];
     }
     $basePaths = $this->accountSpec->getPathTemplates(Request::METHOD_GET);
     foreach ($basePaths as $basePath) {
         $data[$basePath] = [$basePath, 'account'];
     }
     return $data;
 }