コード例 #1
0
ファイル: Job.php プロジェクト: martinsv/bart
 /**
  * Job constructor. Loads metadata about a project.
  * @param Connection $connection
  * @param string $projectPath This parameter specifies the location of the Jenkins Job.
  * For example, if your Job is defined in the following third level project: Base->Build->Example,
  * you must pass in the full path to the project, 'job/Base/job/Build/job/Example'.
  */
 public function __construct(Connection $connection, $projectPath)
 {
     if (!is_string($projectPath)) {
         throw new \InvalidArgumentException('The projectPath must be of type string');
     }
     $this->connection = $connection;
     $this->logger = Log4PHP::getLogger(__CLASS__);
     if (!Strings::startsWith($projectPath, '/')) {
         $projectPath = "/{$projectPath}";
     }
     if (Strings::endsWith($projectPath, '/')) {
         $projectPath = substr($projectPath, 0, strlen($projectPath) - 1);
     }
     $projects = explode('/job/', $projectPath);
     unset($projects[0]);
     $this->baseApiPath = '/';
     foreach ($projects as $project) {
         $projectEncoded = rawurlencode($project);
         $this->baseApiPath .= "job/{$projectEncoded}/";
     }
     $this->metadata = $this->getJson(array());
     if (!isset($this->metadata['buildable'])) {
         throw new \InvalidArgumentException("The project at path '{$this->baseApiPath}'' is disabled");
     }
     $this->setDefaultParameters();
 }
コード例 #2
0
ファイル: StringsTest.php プロジェクト: martinsv/bart
 /**
  * @dataProvider dataProviderTestEndsWithInvalidTypes
  * @param string $fullString
  * @param string $subString
  */
 public function testEndsWithInvalidTypes($fullString, $subString)
 {
     $this->setExpectedException('\\InvalidArgumentException');
     Strings::endsWith($fullString, $subString);
 }