public function testConstructor() { $factory = new Factory(); $repository = $this->getRepositoryMock(); $workspaceName = 'asdfads'; $userID = 'abcd'; $cred = new SimpleCredentials($userID, 'xxxx'); $cred->setAttribute('test', 'toast'); $cred->setAttribute('other', 'value'); $transport = $this->getTransportStub(); $transport->expects($this->any())->method('getNamespaces')->will($this->returnValue(array())); $s = new Session($factory, $repository, $workspaceName, $cred, $transport); $this->assertSame($repository, $s->getRepository()); $this->assertSame($userID, $s->getUserID()); $this->assertSame(array('test', 'other'), $s->getAttributeNames()); $this->assertSame('toast', $s->getAttribute('test')); $this->assertSame('value', $s->getAttribute('other')); }
public function testConstructor() { $factory = new Factory(); $repository = $this->getMock('Jackalope\\Repository', array(), array($factory), '', false); $workspaceName = 'asdfads'; $userID = 'abcd'; $cred = new SimpleCredentials($userID, 'xxxx'); $cred->setAttribute('test', 'toast'); $cred->setAttribute('other', 'value'); $transport = $this->getMockBuilder('Jackalope\\Transport\\TransportInterface')->disableOriginalConstructor()->getMock(array('login', 'getRepositoryDescriptors', 'getNamespaces'), array($factory, 'http://example.com')); $transport->expects($this->any())->method('getNamespaces')->will($this->returnValue(array())); $s = new Session($factory, $repository, $workspaceName, $cred, $transport); $this->assertSame($repository, $s->getRepository()); $this->assertSame($userID, $s->getUserID()); $this->assertSame(array('test', 'other'), $s->getAttributeNames()); $this->assertSame('toast', $s->getAttribute('test')); $this->assertSame('value', $s->getAttribute('other')); }
/** * Initialize basic information common to nodes and properties * * @param FactoryInterface $factory the object factory * @param string $path The normalized and absolute path to this item * @param Session $session * @param ObjectManager $objectManager * @param boolean $new can be set to true to tell the object that it has * been created locally */ protected function __construct(FactoryInterface $factory, $path, Session $session, ObjectManager $objectManager, $new = false) { $this->factory = $factory; $this->valueConverter = $this->factory->get('PHPCR\\Util\\ValueConverter'); $this->session = $session; $this->objectManager = $objectManager; $this->setState($new ? self::STATE_NEW : self::STATE_CLEAN); if (!$new && $session->getRepository()->getDescriptor(RepositoryInterface::OPTION_TRANSACTIONS_SUPPORTED)) { if ($session->getWorkspace()->getTransactionManager()->inTransaction()) { // properly set previous state in case we get into a rollback $this->savedState = self::STATE_CLEAN; } } $this->setPath($path); }