/**
  * Callback function for comparing the keys of $testable1 and $testable2.
  *
  * @param Tx_Phpunit_Testable $testable1 the first item to compare
  * @param Tx_Phpunit_Testable $testable2 the second item to compare
  *
  * @return integer
  *         1 if both items need to be swapped, 0 if they have the same key,
  *         and -1 if the order is okay.
  */
 public function sortTestablesByKey(Tx_Phpunit_Testable $testable1, Tx_Phpunit_Testable $testable2)
 {
     return strcmp($testable1->getKey(), $testable2->getKey());
 }
 /**
  * @test
  */
 public function renderCreatesIconPathWithHtmlSpecialChars()
 {
     $extensionKey = 'phpunit';
     $testable = new Tx_Phpunit_Testable();
     $testable->setKey($extensionKey);
     $testable->setIconPath(ExtensionManagementUtility::extPath('phpunit') . 'ext_&_icon.gif');
     $subject = new Tx_Phpunit_ViewHelpers_ExtensionSelectorViewHelper();
     $subject->injectOutputService($this->outputService);
     $subject->injectUserSettingService($this->userSettingsService);
     /** @var $testFinder Tx_Phpunit_Service_TestFinder|PHPUnit_Framework_MockObject_MockObject */
     $testFinder = $this->getMock('Tx_Phpunit_Service_TestFinder', array('getTestablesForEverything'));
     $testFinder->expects(self::any())->method('getTestablesForEverything')->will(self::returnValue(array($extensionKey => $testable)));
     $subject->injectTestFinder($testFinder);
     $subject->render();
     self::assertContains(htmlspecialchars($testable->getIconPath()), $this->outputService->getCollectedOutput());
 }
 /**
  * @test
  */
 public function getTestablesForExtensionsSortsExtensionsByNsmeInAscendingOrder()
 {
     $testableForFoo = new Tx_Phpunit_Testable();
     $testableForFoo->setKey('foo');
     $testableForBar = new Tx_Phpunit_Testable();
     $testableForBar->setKey('bar');
     /** @var $testFinder Tx_Phpunit_Service_TestFinder|PHPUnit_Framework_MockObject_MockObject */
     $testFinder = $this->getMock('Tx_Phpunit_Service_TestFinder', array('getLoadedExtensionKeys', 'getExcludedExtensionKeys', 'findTestsPathForExtension', 'createTestableForSingleExtension'));
     $testFinder->expects($this->once())->method('getLoadedExtensionKeys')->will($this->returnValue(array('foo', 'bar')));
     $testFinder->expects($this->once())->method('getExcludedExtensionKeys')->will($this->returnValue(array()));
     $testFinder->expects($this->at(2))->method('createTestableForSingleExtension')->with('foo')->will($this->returnValue($testableForFoo));
     $testFinder->expects($this->at(3))->method('createTestableForSingleExtension')->with('bar')->will($this->returnValue($testableForBar));
     $this->assertSame(array('bar' => $testableForBar, 'foo' => $testableForFoo), $testFinder->getTestablesForExtensions());
 }
 /**
  * @test
  *
  * @expectedException InvalidArgumentException
  */
 public function setIconPathWithEmptyStringThrowsException()
 {
     $this->fixture->setIconPath('');
 }
Beispiel #5
0
 /**
  * Loads all files containing test cases for the given testable.
  *
  * @param Tx_Phpunit_Testable $testable the testable for which to load all test case files
  *
  * @return void
  */
 protected function loadAllFilesContainingTestCasesForSingleTestable(Tx_Phpunit_Testable $testable)
 {
     $testsPath = $testable->getTestsPath();
     $testCaseFileNames = $this->testCaseService->findTestCaseFilesInDirectory($testsPath);
     foreach ($testCaseFileNames as $testCaseFileName) {
         require_once realpath($testsPath . $testCaseFileName);
     }
 }