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);
     }
     $transport = $this->getTransport();
     $repository = new \Jackalope\Repository(null, $transport);
     $session = $repository->login(new \PHPCR\SimpleCredentials("user", "passwd"), $GLOBALS['phpcr.workspace']);
     $a = $session->getNode('/')->addNode('node-a');
     $a->addNode('child-a')->setProperty('prop', 'aa');
     $a->addNode('child-b')->setProperty('prop', 'ab');
     $b = $session->getNode('/')->addNode('node-b');
     $b->addNode('child-a')->setProperty('prop', 'ba');
     $b->addNode('child-b')->setProperty('prop', 'bb');
     $session->save();
 }
Example #2
0
 public function testConstructor()
 {
     $factory = new \Jackalope\Factory();
     $credentials = new \PHPCR\SimpleCredentials('test', 'cred');
     $workspaceName = 'sadf3sd';
     $transport = $this->getMock('Jackalope\\Transport\\Davex\\Client', array('login', 'getRepositoryDescriptors'), array($factory, 'http://example.com'));
     $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')));
     $repo = new \Jackalope\Repository($factory, null, $transport);
     $session = $repo->login($credentials, $workspaceName);
     $this->assertType('Jackalope\\Session', $session);
     $this->assertSame(array('bla'), $repo->getDescriptorKeys());
     $this->assertSame('bli', $repo->getDescriptor('bla'));
 }