public function testFactoryCreatesBuildWithDefaults() { $build = Build::factory($this->jenkins, "foo", new JsonData(array('number' => 42))); $this->assertEquals(array(), $build->actions); $this->assertEquals(array(), $build->artifacts); $this->assertFalse($build->building); $this->assertEquals("", $build->builtOn); $this->assertEquals(array(), $build->changeSet); $this->assertEquals(array(), $build->culprits); $this->assertEquals("", $build->description); $this->assertEquals(0, $build->duration); $this->assertEquals(0, $build->estimatedDuration); $this->assertEquals("", $build->executor); $this->assertEquals("", $build->fullDisplayName); $this->assertEquals("", $build->id); $this->assertFalse($build->keepLog); $this->assertEquals("UNKNOWN", $build->result); $this->assertEquals(0, $build->timestamp); }
/** * (non-PHPdoc) * @see \mogman1\Jenkins\ApiObject::updateImpProperties() */ protected function updateImpProperties(JsonData $data) { //url and name are not updated since, once they are set, they should never change //TODO: figure out what actions are $this->actions = $data->get('actions', array()); $this->buildable = $data->get('buildable', TRUE); $this->builds = Build::multiFactory($this->conn, $this->name, $data->get('builds', array())); $this->color = $data->get('color', "gray"); $this->concurrentBuild = $data->get('concurrentBuild', FALSE); $this->description = $data->get('description', ""); $this->displayName = $data->get('displayName', ""); $this->displayNameOrNull = $data->get('displayNameOrNull', NULL); $this->downstreamProjects = $data->get('downstreamProjects', array()); //TODO: create health report object $this->healthReport = $data->get('healthReport', array()); $this->inQueue = $data->get('inQueue', FALSE); $this->keepDependencies = $data->get('keepDependencies', FALSE); $this->nextBuildNumber = $data->get('nextBuildNumber', "0"); $this->property = $data->get('property', array()); $this->queueItem = $data->get('queueItem', NULL); $this->scm = $data->get('scm', array()); $this->upstreamProjects = $data->get('upstreamProjects', array()); $build = $data->get('firstBuild', array()); $this->firstBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL; $build = $data->get('lastBuild', array()); $this->lastBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL; $build = $data->get('lastCompletedBuild', array()); $this->lastCompletedBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL; $build = $data->get('lastFailedBuild', array()); $this->lastFailedBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL; $build = $data->get('lastStableBuild', array()); $this->lastStableBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL; $build = $data->get('lastSuccessfulBuild', array()); $this->lastSuccessfulBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL; $build = $data->get('lastUnstableBuild', array()); $this->lastUnstableBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL; $build = $data->get('lastUnsuccessfulBuild', array()); $this->lastUnsuccessfulBuild = $build ? Build::factory($this->conn, $this->name, new JsonData($build)) : NULL; }
public static function multiFactory(Jenkins $conn, $jobName, array $data) { $builds = array(); foreach ($data as $buildData) { $builds[] = Build::factory($conn, $jobName, new JsonData($buildData)); } return $builds; }
protected function updateImpProperties(JsonData $data) { //id and url are not updated since, once they are set, they should never change //TODO: figure out what actions are $this->actions = $data->get('actions', array()); $this->blocked = $data->get('blocked', FALSE); $this->buildable = $data->get('buildable', FALSE); $this->cancelled = $data->get('cancelled', FALSE); $this->inQueueSince = $data->get('inQueueSince', "0"); $this->params = $this->parseParamsString($data->get('params', "")); $this->stuck = $data->get('stuck', FALSE); $this->timestamp = $data->get('timestamp', "0"); $this->why = $data->get('why', ""); $task = $data->get('task', array()); $this->task = $task ? Job::factory($this->conn, new JsonData($data->get('task', array()))) : NULL; $build = $data->get('executable', array()); $this->executable = $build ? Build::factory($this->conn, $this->task->name, new JsonData($build)) : NULL; }