public function test_sync_should_get_repositories_from_github_and_save_them()
 {
     $employee = Employee::builder()->withUsername("jgiovaresco")->build();
     $repositories = array(Repository::builder()->withName("repo1")->build(), Repository::builder()->withName("repo2")->build());
     $this->mockGitHubRestClient->expects($this->once())->method('listUserRepositories')->with('jgiovaresco')->willReturn($repositories);
     $this->mockRepositoryRepository->expects($this->at(0))->method('save')->with($this->equalTo($repositories[0]));
     $this->mockRepositoryRepository->expects($this->at(1))->method('save')->with($this->equalTo($repositories[1]));
     $this->syncService->sync($employee);
 }
 /**
  * @param $companyName
  * @return Employee[]
  */
 public function allEmployeesOfCompany($companyName)
 {
     $employees = array();
     $this->findEmployeesOfCompanyStatement->execute(array(":name" => $companyName));
     foreach ($this->findEmployeesOfCompanyStatement->fetchAll() as $row) {
         array_push($employees, Employee::builder()->withId($row["employee_id"])->withUsername($row["employee_username"])->build());
     }
     return $employees;
 }
 function test_updateEmployeeRepositories_should_update_employees_repository()
 {
     $nterray = Employee::builder()->withUsername("nterray")->build();
     $sandrae = Employee::builder()->withUsername("sandrae")->build();
     $employees = array($nterray, $sandrae);
     $this->mockEmployeeQuery->expects($this->once())->method('allEmployeesOfCompany')->with($this->equalTo('Enalean'))->willReturn($employees);
     $this->mockRepositoriesSyncService->expects($this->at(0))->method('sync')->with($this->equalTo($nterray));
     $this->mockRepositoriesSyncService->expects($this->at(1))->method('sync')->with($this->equalTo($sandrae));
     $this->action->updateEmployeeRepositories('Enalean');
 }
    public function testListUserRepositories()
    {
        $this->mockRequest->expects($this->once())->method('expectsJson')->willReturn($this->mockRequest);
        $this->mockRequest->expects($this->once())->method('uri')->with($this->equalTo('https://api.github.com/users/jgiovaresco/repos'))->willReturn($this->mockRequest);
        $this->mockRequest->expects($this->once())->method('send')->willReturn(new \Httpful\Response('[{
						"id": 123,
						"name": ".vim"
					},{
						"id": 124,
						"name": "repocount"
					}]', "HTTP/1.1 200 OK\n\t\t\t\t\tContent-Type: application/json\n\t\t\t\t\tConnection: keep-alive\n\t\t\t\t\tTransfer-Encoding: chunked\r\n", $req = \Httpful\Request::init()->sendsAndExpects(\Httpful\Mime::JSON)));
        $repositories = $this->gitHubRestClient->listUserRepositories(Employee::builder()->withId('123')->withUsername('jgiovaresco')->build());
        expect($repositories)->to->have->length(2);
        expect($repositories[0]->name())->to->equal('.vim');
        expect($repositories[1]->name())->to->equal('repocount');
    }
Esempio n. 5
0
 function test_repositories_should_return_employee_repositories()
 {
     $employee = Employee::builder()->withUsername('jgiovaresco')->withRepository('repo1')->withRepository('repo2')->build();
     expect($employee->repositories())->to->be->an('array')->and->has->length(2);
     expect($employee->repositories())->to->include('repo1')->and->to->include('repo2');
 }