public function testFetch() { $username = '******'; $commitHash = 'commit-hash'; $referenceName = 'HEAD'; $factory = $this->getFactory(); $user = $this->prophesize(UserInterface::class); $user->getUsername()->willReturn($username); $commit = $this->prophesize(CommitInterface::class); $commit->getHash()->willReturn($commitHash); $reference = new Reference(); $reference->setPolicyCollection(new PolicyCollection()); $reference->setUser($user->reveal()); $reference->setCommit($commit->reveal()); $reference->setName($referenceName); $database = $this->prophesize(DatabaseInterface::class); $database->fetch($referenceName, Reference::class)->willReturn($reference); $commitManager = $this->prophesize(CommitManagerInterface::class); $commitManager->fetch($commitHash, Commit::class)->willReturn($commit->reveal()); $manager = new ReferenceManager($database->reveal(), $this->getUserProvider(), $factory, 'http://symcloud.lo'); $reference = $manager->fetch($referenceName); $this->assertEquals($user->reveal(), $reference->getUser()); $this->assertEquals($referenceName, $reference->getName()); $this->assertEquals($commit->reveal(), $reference->getCommit()); }
/** * {@inheritdoc} */ public function create($name, UserInterface $user, CommitInterface $commit) { $reference = new Reference(); $reference->setHash($this->createHash($user, $name)); $reference->setName($name); $reference->setUser($user); $reference->setCommit($commit); return $this->database->store($reference); }
/** * @dataProvider dataProvider * @param string $name * @param Commit $commit * @param Commit $commit2 * @param Tree $tree * @param UserInterface $user */ public function testUpdateReference($name, Commit $commit, Commit $commit2, Tree $tree, UserInterface $user) { $hash = '123-123-123'; $database = $this->getDatabase(); $database->store($tree); $database->store($commit); $database->store($commit2); $reference = new Reference(); $reference->setHash($hash); $reference->setCommit($commit); $reference->setUser($user); $reference->setName($name); $database->store($reference); $referenceManager = $this->getReferenceManager(); $reference2 = $referenceManager->update($reference, $commit2); $this->assertEquals($reference2, $reference); /** @var ReferenceInterface $result */ $result = $database->fetch($hash, Reference::class); $this->assertEquals($hash, $result->getHash()); $this->assertEquals($name, $result->getName()); $this->assertEquals($commit2->getHash(), $result->getCommit()->getHash()); $this->assertEquals($user->getUsername(), $result->getUser()->getUsername()); }