function test_get_last_commit() { $commit = new Commit(WP_Gistpen::$plugin_name, WP_Gistpen::$version); $commit->set_ID(1); $this->mock_commit->shouldReceive('get_ID')->once()->andReturn(2); $this->history->set_commits(array(1 => $commit, 2 => $this->mock_commit)); $this->assertNotEquals($commit, $this->history->get_last_commit()); }
/** * Validate and add a Commit to the History * * @param Commit $commit * @since 0.5.0 */ public function add_commit($commit) { if (!$commit instanceof Commit) { throw new \Exception('Commit objects only added to Commits'); } $commit_id = $commit->get_ID(); if (null !== $commit_id) { $this->commits[$commit_id] = $commit; } else { $this->commits[] = $commit; } }
/** * Sets the status on the Gist array based on * the commit's status * * @param array $gist Array of Gist API data * @param Meta $commit Commit object * @return array modified array of Gist API data * @since 0.5.0 */ protected function set_status($gist, $commit) { if ('publish' === $commit->get_status()) { $gist['public'] = true; } else { $gist['public'] = false; } return $gist; }