コード例 #1
0
 function it_also_validates_methods(CollectionValidator $collectionValidator, MethodValidator $methodValidator, Contract $model, Method $method)
 {
     $constants = array();
     $contracts = array();
     $methods = array($method);
     $violationCollection1 = new ViolationCollection();
     $violationCollection2 = new ViolationCollection();
     $violationCollection3 = new ViolationCollection();
     $violationCollection4 = new ViolationCollection();
     $model->getName()->willReturn('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
     $model->allConstants()->willReturn($constants);
     $model->allContracts()->willReturn($contracts);
     $model->allMethods()->willReturn($methods);
     $collectionValidator->validate($constants)->willReturn($violationCollection1);
     $collectionValidator->validate($contracts)->willReturn($violationCollection2);
     $collectionValidator->validate($methods)->willReturn($violationCollection3);
     $methodValidator->validate($method)->willReturn($violationCollection4);
     $this->validate($model);
 }
コード例 #2
0
ファイル: Model.php プロジェクト: sergeycherepanov/m2gen
 /**
  * @param Contract $contract
  * @param $filePath
  * @param array $fqns
  * @return $this
  */
 protected function dumpContract(Contract $contract, $filePath, array $fqns = [])
 {
     $fileDir = dirname($filePath);
     $file = File::make($filePath);
     foreach ($contract->allContracts() as $_contract) {
         $fqns[] = $_contract->getFullyQualifiedName();
     }
     sort($fqns);
     foreach ($fqns as $name) {
         $file->addFullyQualifiedName(new FullyQualifiedName($name));
     }
     $file->setStructure($contract);
     $this->filesystem->mkdir($fileDir, 0755);
     $this->filesystem->dumpFile($filePath, Build::prettyPrinter()->generateCode($file), 0755);
     return $this;
 }