public function testPopulateWithExampleData() { $repository = new Repository(); $repository->populate($this->loadJsonFixture('fixture_repository.json')); $this->assertEquals(1296269, $repository->getId()); $this->assertEquals('Hello-World', $repository->getName()); $this->assertFalse($repository->isPrivate()); $this->assertFalse($repository->isFork()); $this->assertEquals('This your first repo!', $repository->getDescription()); $this->assertEquals('git@github.com:octocat/Hello-World.git', $repository->getSshUrl()); $this->assertEquals('octocat/Hello-World', $repository->getFullName()); $this->assertEquals('master', $repository->getDefaultBranch()); $this->assertInstanceOf('MPScholten\\GitHubApi\\Api\\User\\User', $repository->getOwner()); $this->assertEquals('octocat', $repository->getOwner()->getLogin()); }
/** * @param $owner string The login name of the repository owner, e.g. "octocat" * @param $name string The repository name, e.g. "Hello-World" * @throws Exception\GithubException In case the repository was not found * @return Repository */ public function getRepository($owner, $name) { $repository = new Repository($this->client); $repository->populate(['owner' => ['login' => $owner], 'name' => $name]); try { $repository->getId(); } catch (GithubException $e) { throw new GithubException(sprintf('Repository %s was not found.', $name), 0, $e); } return $repository; }