public function setUp() { parent::setUp(); $conn = $this->getConnection(); $options = array('disable_fks' => $conn->getDatabasePlatform() instanceof SqlitePlatform); $schema = new RepositorySchema($options, $conn); // do not use reset as we want to ignore exceptions on drop foreach ($schema->toDropSql($conn->getDatabasePlatform()) as $statement) { try { $conn->exec($statement); } catch (\Exception $e) { // ignore } } foreach ($schema->toSql($conn->getDatabasePlatform()) as $statement) { $conn->exec($statement); } $this->transport = new \Jackalope\Transport\DoctrineDBAL\Client(new \Jackalope\Factory(), $conn); $this->transport->createWorkspace('default'); $this->repository = new \Jackalope\Repository(null, $this->transport); try { $this->transport->createWorkspace($GLOBALS['phpcr.workspace']); } catch (\PHPCR\RepositoryException $e) { if ($e->getMessage() != "Workspace '" . $GLOBALS['phpcr.workspace'] . "' already exists") { // if the message is not that the workspace already exists, something went really wrong throw $e; } } $this->session = $this->repository->login(new \PHPCR\SimpleCredentials("user", "passwd"), $GLOBALS['phpcr.workspace']); }
public function testConstructor() { $factory = new Factory(); $credentials = new SimpleCredentials('test', 'cred'); $workspaceName = 'sadf3sd'; $transport = $this->getTransportStub(); $transport->expects($this->once())->method('login')->with($this->equalTo($credentials), $this->equalTo($workspaceName))->will($this->returnValue(true)); $transport->expects($this->once())->method('getRepositoryDescriptors')->will($this->returnValue(array('bla' => 'bli'))); $transport->expects($this->any())->method('getNamespaces')->will($this->returnValue(array())); $repo = new Repository($factory, $transport); $session = $repo->login($credentials, $workspaceName); $this->assertInstanceOf('Jackalope\\Session', $session); $this->assertContains('bla', $repo->getDescriptorKeys()); $this->assertSame('bli', $repo->getDescriptor('bla')); }
public function setUp() { parent::setUp(); $conn = $this->getConnection(); $this->loadFixtures($conn); $this->transport = $this->getClient($conn); $this->transport->createWorkspace('default'); $this->repository = new \Jackalope\Repository(null, $this->transport); try { $this->transport->createWorkspace($GLOBALS['phpcr.workspace']); } catch (\PHPCR\RepositoryException $e) { if ($e->getMessage() != "Workspace '" . $GLOBALS['phpcr.workspace'] . "' already exists") { // if the message is not that the workspace already exists, something went really wrong throw $e; } } $this->session = $this->repository->login(new \PHPCR\SimpleCredentials("user", "passwd"), $GLOBALS['phpcr.workspace']); }