PHPUnit collects the data from a dataProvider early during test execution, so the PersistenceManager instance is NULL, if used directly in the provider. Returning a closure that is re-bound during the the test makes this work.
Last active
August 29, 2015 14:20
-
-
Save kdambekalns/6fd1e3b924c07acb5a2d to your computer and use it in GitHub Desktop.
Using injected properties of Flow functional test in @dataProvider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Testcase for FooController | |
*/ | |
class FooControllerTest extends \TYPO3\Flow\Tests\FunctionalTestCase { | |
/** | |
* @return array | |
*/ | |
public function invalidFooIdentifiers() { | |
return array( | |
array(function() {return 'abcdef123456';}), | |
array(function() {return $this->persistenceManager->getIdentifierByObject($this->foo);}), | |
); | |
} | |
/** | |
* @test | |
* @dataProvider invalidFooIdentifiers | |
*/ | |
public function invalidFooIdentifierDoesSomething(\Closure $invalidFooIdentifierClosure) { | |
$invalidAppIdentifier = $invalidAppIdentifierClosure->bindTo($this)->__invoke(); | |
// ... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment