/**
  * @test
  * @return void
  */
 public function getLatestCompatibleExtensionByIntegerVersionDependencyWillReturnExtensionModelOfLatestExtension()
 {
     $extension1 = new \TYPO3\CMS\Extensionmanager\Domain\Model\Extension();
     $extension1->setExtensionKey('foo');
     $extension1->setVersion('1.0.0');
     $extension2 = new \TYPO3\CMS\Extensionmanager\Domain\Model\Extension();
     $extension2->setExtensionKey('bar');
     $extension2->setVersion('1.0.42');
     $className = uniqid('objectStorage');
     eval('class ' . $className . ' {' . 'public $extensions = array();' . 'public function getFirst() {' . '  return $this->extensions[0];' . '}' . '}');
     $myStorage = new $className();
     $myStorage->extensions[] = $extension1;
     $myStorage->extensions[] = $extension2;
     $dependencyModelMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Model\\Dependency', array('getIdentifier'));
     $dependencyModelMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('foobar'));
     $dependencyUtility = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Utility\\DependencyUtility', array('getLowestAndHighestIntegerVersions'));
     $dependencyUtility->expects($this->once())->method('getLowestAndHighestIntegerVersions')->will($this->returnValue(array('lowestIntegerVersion' => 1000000, 'highestIntegerVersion' => 2000000)));
     $extensionRepositoryMock = $this->getAccessibleMock('TYPO3\\CMS\\Extensionmanager\\Domain\\Repository\\ExtensionRepository', array('findByVersionRangeAndExtensionKeyOrderedByVersion'));
     $extensionRepositoryMock->expects($this->once())->method('findByVersionRangeAndExtensionKeyOrderedByVersion')->with('foobar', 1000000, 2000000)->will($this->returnValue($myStorage));
     $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
     $extension = $dependencyUtility->_call('getLatestCompatibleExtensionByIntegerVersionDependency', $dependencyModelMock);
     $this->assertTrue($extension instanceof \TYPO3\CMS\Extensionmanager\Domain\Model\Extension);
     $this->assertEquals('foo', $extension->getExtensionKey());
 }
 /**
  * @test
  * @return void
  */
 public function getLatestCompatibleExtensionByIntegerVersionDependencyWillReturnExtensionModelOfLatestExtension()
 {
     $extension1 = new \TYPO3\CMS\Extensionmanager\Domain\Model\Extension();
     $extension1->setExtensionKey('foo');
     $extension1->setVersion('1.0.0');
     $extension2 = new \TYPO3\CMS\Extensionmanager\Domain\Model\Extension();
     $extension2->setExtensionKey('bar');
     $extension2->setVersion('1.0.42');
     $myStorage = new \TYPO3\CMS\Extensionmanager\Tests\Unit\Fixtures\LatestCompatibleExtensionObjectStorageFixture();
     $myStorage->extensions[] = $extension1;
     $myStorage->extensions[] = $extension2;
     $dependencyMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Dependency::class, array('getIdentifier'));
     $dependencyMock->expects($this->once())->method('getIdentifier')->will($this->returnValue('foobar'));
     $dependencyUtility = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Utility\DependencyUtility::class, array('getLowestAndHighestIntegerVersions'));
     $dependencyUtility->expects($this->once())->method('getLowestAndHighestIntegerVersions')->will($this->returnValue(array('lowestIntegerVersion' => 1000000, 'highestIntegerVersion' => 2000000)));
     $extensionRepositoryMock = $this->getMock(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository::class, array('findByVersionRangeAndExtensionKeyOrderedByVersion'), array($this->objectManagerMock));
     $extensionRepositoryMock->expects($this->once())->method('findByVersionRangeAndExtensionKeyOrderedByVersion')->with('foobar', 1000000, 2000000)->will($this->returnValue($myStorage));
     $dependencyUtility->_set('extensionRepository', $extensionRepositoryMock);
     $extension = $dependencyUtility->_call('getLatestCompatibleExtensionByIntegerVersionDependency', $dependencyMock);
     $this->assertInstanceOf(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension::class, $extension);
     $this->assertSame('foo', $extension->getExtensionKey());
 }