/**
  * @param SessionInterface|PHPUnit_Framework_MockObject_MockObject $session
  * @return ObjectFactory
  */
 public function getObjectFactory($session = null)
 {
     if ($session === null) {
         $session = $this->getMockBuilder('\\Dkd\\PhpCmis\\SessionInterface')->getMockForAbstractClass();
     }
     $objectFactory = new ObjectFactory();
     $objectFactory->initialize($session);
     return $objectFactory;
 }
 public function testGetPropertyValueByQueryNameReturnsFirstPropertyValueFromSelectedProperty()
 {
     $sessionMock = $this->getMockBuilder('\\Dkd\\PhpCmis\\SessionInterface')->setMethods(array('getObjectFactory', 'getDefaultContext'))->getMockForAbstractClass();
     $objectFactory = new ObjectFactory();
     $objectFactory->initialize($sessionMock);
     $operationContext = new OperationContext();
     $sessionMock->expects($this->once())->method('getObjectFactory')->willReturn($objectFactory);
     $sessionMock->expects($this->any())->method('getDefaultContext')->willReturn($operationContext);
     $values1 = array('foobar', 'barbaz', 'foobaz');
     $property1 = new PropertyString('foo', $values1);
     $property1->setQueryName('baz:foo');
     $values2 = array(123, 234, 345);
     $property2 = new PropertyInteger('bar', $values2);
     $property2->setQueryName('baz:bar');
     $properties = new Properties();
     $properties->addProperties(array($property1, $property2));
     $objectData = new ObjectData();
     $objectData->setProperties($properties);
     $queryResult = new QueryResult($sessionMock, $objectData);
     $this->assertEquals('foobar', $queryResult->getPropertyValueByQueryName('baz:foo'));
     $this->assertEquals(123, $queryResult->getPropertyValueByQueryName('baz:bar'));
     $this->assertEquals(null, $queryResult->getPropertyValueByQueryName('not:exists'));
 }