Exemplo n.º 1
0
 /**
  * Return docker-compose service based on current directory.
  *
  * @return string Service
  */
 public function getCurrentService()
 {
     $directory = $this->project->getCurrentRelativePath();
     $servicePaths = $this->getServiceBuildPaths();
     $dirParts = $this->directoryPathToArray($directory);
     do {
         foreach ($servicePaths as $service => $path) {
             if ($path == $dirParts) {
                 return $service;
             }
         }
     } while (array_pop($dirParts));
     throw new NotWithinServiceException("Directory {$directory} is not within any known service");
 }
Exemplo n.º 2
0
 function it_throws_an_exception_when_not_in_service(Project $project)
 {
     $project->getCurrentRelativePath()->willReturn('');
     $project->getComposeConfigPath()->willReturn('spec/fixtures/docker-compose-nodefault.yml');
     $this->shouldThrow('Dock\\Docker\\Compose\\NotWithinServiceException')->during('getCurrentService');
 }