Skip to content

Instantly share code, notes, and snippets.

@kdambekalns
Last active August 29, 2015 14:20
Show Gist options
  • Save kdambekalns/6fd1e3b924c07acb5a2d to your computer and use it in GitHub Desktop.
Save kdambekalns/6fd1e3b924c07acb5a2d to your computer and use it in GitHub Desktop.

Revisions

  1. kdambekalns revised this gist May 11, 2015. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -20,5 +20,6 @@ public function invalidFooIdentifiers() {
    */
    public function invalidFooIdentifierDoesSomething(\Closure $invalidFooIdentifierClosure) {
    $invalidAppIdentifier = $invalidAppIdentifierClosure->bindTo($this)->__invoke();
    // ...
    // ...
    }
    }
  2. kdambekalns created this gist May 11, 2015.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    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.
    24 changes: 24 additions & 0 deletions gistfile1.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    <?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();
    // ...
    }