Ejemplo n.º 1
0
 /**
  * @test
  */
 public function shouldCompareValuesWithObject()
 {
     $repository = new Repository();
     $repository->setId(777);
     $repository->setSlug('test');
     $this->assertTrue(BuildUtil::compareValues($repository, array('id' => 777, 'slug' => 'test')));
     $this->assertFalse(BuildUtil::compareValues($repository, array('id' => 888, 'slug' => 'test')));
     $this->assertFalse(BuildUtil::compareValues($repository, array('id' => 777, 'slug' => 'test1')));
     $this->assertFalse(BuildUtil::compareValues($repository, array('id' => 777, 'slug' => 'test', 'status' => 'failed')));
 }
Ejemplo n.º 2
0
 public function fetchRepository($slug)
 {
     $repositoryUrl = sprintf('%s/%s.json', $this->apiUrl, $slug);
     $buildsUrl = sprintf('%s/%s/builds.json', $this->apiUrl, $slug);
     $repository = new Repository();
     $repositoryArray = json_decode($this->browser->get($repositoryUrl)->getContent(), true);
     if (!$repositoryArray) {
         throw new \UnexpectedValueException(sprintf('Response is empty for url %s', $repositoryUrl));
     }
     $repository->fromArray($repositoryArray);
     $buildCollection = new BuildCollection(json_decode($this->browser->get($buildsUrl)->getContent(), true));
     $repository->setBuilds($buildCollection);
     return $repository;
 }
Ejemplo n.º 3
0
 /**
  * @test
  */
 public function shouldNotReturnsLastBuild()
 {
     $repository = new Repository();
     $repository->setLastBuildId(333);
     $repository->setBuilds(array(array('id' => 111), array('id' => 222)));
     $lastBuild = $repository->getLastBuild();
     $this->assertFalse($lastBuild);
 }
 /**
  * @test
  */
 public function shouldNotContainElement()
 {
     $repository = new Repository();
     $repository->setId(666);
     $otherRepository = new Repository();
     $otherRepository->setId(777);
     $repositoryCollection = new RepositoryCollection();
     $repositoryCollection->add($repository);
     $this->assertFalse($repositoryCollection->contains($otherRepository));
 }