Esempio n. 1
0
 /**
  * Returns a greater than or equal criterion used for matching objects against a query
  *
  * @param string $propertyName The name of the property to compare against
  * @param mixed $operand The value to compare with
  * @return Qom\Comparison
  * @throws InvalidQueryException if used on a multi-valued property or with a non-literal/non-DateTime operand
  * @api
  */
 public function greaterThanOrEqual($propertyName, $operand)
 {
     if ($this->classSchema->isMultiValuedProperty($propertyName)) {
         throw new InvalidQueryException('Property "' . $propertyName . '" must not be multi-valued', 1276774883);
     }
     if (!$operand instanceof \DateTimeInterface && !TypeHandling::isLiteral(gettype($operand))) {
         throw new InvalidQueryException('Operand must be a literal or DateTime, was ' . gettype($operand), 1276774884);
     }
     return $this->qomFactory->comparison($this->qomFactory->propertyValue($propertyName, '_entity'), QueryInterface::OPERATOR_GREATER_THAN_OR_EQUAL_TO, $operand);
 }
 /**
  * @test
  */
 public function mapSplObjectStorageCreatesSplObjectStorage()
 {
     $objectData = [['value' => ['mappedObject1']], ['value' => ['mappedObject2']]];
     $classSchema = new ClassSchema('TYPO3\\Post');
     $classSchema->addProperty('firstProperty', 'SplObjectStorage');
     $dataMapper = $this->getAccessibleMock(Persistence\Generic\DataMapper::class, ['mapToObject']);
     $dataMapper->expects($this->at(0))->method('mapToObject')->with($objectData[0]['value'])->will($this->returnValue(new \stdClass()));
     $dataMapper->expects($this->at(1))->method('mapToObject')->with($objectData[1]['value'])->will($this->returnValue(new \stdClass()));
     $dataMapper->_call('mapSplObjectStorage', $objectData);
 }
 /**
  * @test
  */
 public function getUriPatternReturnsBasedOnTheIdentityPropertiesOfTheObjectTypeIfNoPatternWasSpecified()
 {
     $this->mockClassSchema->expects($this->once())->method('getIdentityProperties')->will($this->returnValue(['property1' => 'string', 'property2' => 'integer', 'property3' => 'DateTime']));
     $this->identityRoutePart->setObjectType('SomeObjectType');
     $this->assertSame('{property1}/{property2}/{property3}', $this->identityRoutePart->getUriPattern());
 }
Esempio n. 4
0
 /**
  * Assigns the repository of any aggregate root to all it's
  * subclasses, unless they are aggregate root already.
  *
  * @param ClassSchema $classSchema
  * @return void
  */
 protected function makeChildClassesAggregateRoot(ClassSchema $classSchema)
 {
     foreach ($this->getAllSubClassNamesForClass($classSchema->getClassName()) as $childClassName) {
         if (!isset($this->classSchemata[$childClassName]) || $this->classSchemata[$childClassName]->isAggregateRoot()) {
             continue;
         }
         $this->classSchemata[$childClassName]->setRepositoryClassName($classSchema->getRepositoryClassName());
         $this->makeChildClassesAggregateRoot($this->classSchemata[$childClassName]);
     }
 }
 /**
  * @test
  * @dataProvider collectionTypes
  * @param string $type
  */
 public function isMultiValuedPropertyReturnsTrueForCollectionTypes($type)
 {
     $classSchema = new ClassSchema('SomeClass');
     $classSchema->addProperty('testProperty', $type);
     $this->assertTrue($classSchema->isMultiValuedProperty('testProperty'));
 }