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); }
/** * @param PullRequest $pullRequest * * @return PullRequests */ public function add(PullRequest $pullRequest) { $this->pullRequests = $this->pullRequests->add($pullRequest); }