public function testAdd()
 {
     $pullRequest = PullRequest::fromArray(['title' => 'a', 'repositoryName' => 'foo/bar', 'url' => 'http://www.example.com/', 'loneliness' => 42]);
     $this->assertEmpty($this->repository->all());
     $this->repository->add($pullRequest);
     $this->assertNotEmpty($this->repository->all());
 }
 public function testPersistUpsert()
 {
     $testStruct = ['title' => 'a', 'repositoryName' => 'foo/bar', 'url' => 'http://www.example.com/', 'loneliness' => 42];
     $this->entityPersister->shouldReceive('loadAll')->andReturn($this->objects);
     $pullRequest = PullRequest::fromArray($testStruct);
     $this->repository->add($pullRequest);
     $pullRequest = PullRequest::fromArray($testStruct);
     $this->repository->add($pullRequest);
 }
 public function testImmutability()
 {
     $pullRequests = new PullRequests();
     $pullRequest = PullRequest::fromArray(['title' => 'a', 'repositoryName' => 'foo/bar', 'url' => 'http://www.example.com/', 'loneliness' => 42]);
     $newPullRequests = $pullRequests->add($pullRequest);
     $anotherPullRequests = $pullRequests->add($pullRequest);
     $this->assertNotSame($pullRequest, $newPullRequests);
     $this->assertNotSame($pullRequest, $anotherPullRequests);
     $this->assertNotSame($newPullRequests, $anotherPullRequests);
     $this->assertEquals($newPullRequests, $anotherPullRequests);
 }
 public function testInstantiationWithGetters()
 {
     $title = 'foobar';
     $repositoryName = 'foo/bar';
     $url = 'https://www.lonelypullrequests.com/';
     $loneliness = 42;
     $pullRequest = PullRequest::fromArray(array('title' => $title, 'repositoryName' => $repositoryName, 'url' => $url, 'loneliness' => $loneliness));
     $this->assertInstanceOf('\\LonelyPullRequests\\Domain\\PullRequest', $pullRequest);
     $this->assertInstanceOf('\\LonelyPullRequests\\Domain\\Title', $pullRequest->title());
     $this->assertEquals($title, $pullRequest->title()->toString());
     $this->assertInstanceOf('\\LonelyPullRequests\\Domain\\RepositoryName', $pullRequest->repositoryName());
     $this->assertEquals($repositoryName, $pullRequest->repositoryName()->toString());
     $this->assertInstanceOf('\\LonelyPullRequests\\Domain\\Url', $pullRequest->url());
     $this->assertEquals($url, $pullRequest->url()->toString());
     $this->assertInstanceOf('\\LonelyPullRequests\\Domain\\Loneliness', $pullRequest->loneliness());
     $this->assertEquals($loneliness, $pullRequest->loneliness()->toString());
 }
 /**
  * @param Loneliness $loneliness
  *
  * @return PullRequest
  */
 public function pullRequest(Loneliness $loneliness)
 {
     return PullRequest::create($this->title(), $this->repositoryName(), $this->url(), $loneliness);
 }