public function dataProvider() { $username = '******'; $message = 'My message'; $user = $this->getUserProvider()->loadUserByUsername($username); $tree = new Tree(); $tree->setPolicyCollection(new PolicyCollection()); $tree->setName(''); $tree->setPath('/'); $commit = new Commit(); $commit->setPolicyCollection(new PolicyCollection()); $commit->setMessage('init'); $commit->setCommitter($user); $commit->setCreatedAt(new \DateTime()); $commit->setTree($tree); $commit->setParentCommit(null); $commit2 = new Commit(); $commit2->setPolicyCollection(new PolicyCollection()); $commit2->setMessage($message); $commit2->setCommitter($user); $commit2->setCreatedAt(new \DateTime()); $commit2->setTree($tree); $commit2->setParentCommit($commit); return array(array('my-hash', $commit, $commit2, $tree, $user)); }
public function testFetchCommit() { $commitManager = $this->getCommitManager(); $database = $this->getDatabase(); $username = '******'; $message = 'My message'; $user = $this->getUserProvider()->loadUserByUsername($username); $tree = new Tree(); $tree->setPolicyCollection(new PolicyCollection()); $tree->setName(''); $tree->setPath('/'); $database->store($tree); $commit = new Commit(); $commit->setPolicyCollection(new PolicyCollection()); $commit->setMessage($message); $commit->setCommitter($user); $commit->setCreatedAt(new \DateTime()); $commit->setTree($tree); $commit->setParentCommit(null); $database->store($commit); $commitManager->fetch($commit->getHash()); $this->assertEquals($tree->getHash(), $commit->getTree()->getHash()); $this->assertEquals($user->getUsername(), $commit->getCommitter()->getUsername()); $this->assertEquals($message, $commit->getMessage()); $this->assertInstanceOf(\DateTime::class, $commit->getCreatedAt()); $this->assertEquals(null, $commit->getParentCommit()); }
/** * {@inheritdoc} */ public function createTree($name, TreeInterface $parent) { $tree = new Tree(); $tree->setPolicyCollection(new PolicyCollection()); $tree->setName($name); $tree->setPath(sprintf('%s/%s', $parent->getPath(), $name)); $parent->setChild($name, $tree); return $tree; }