You are here

class ClosureTest in Coder 8.3.x

Same name and namespace in other branches
  1. 8.3 tests/DrupalPractice/good/good.php \ClosureTest
  2. 8.2 coder_sniffer/DrupalPractice/Test/good/good.php \ClosureTest

Testing closures.

Hierarchy

Expanded class hierarchy of ClosureTest

File

tests/DrupalPractice/good/good.php, line 129

View source
class ClosureTest extends TestCase {

  /**
   * Use $this in a closure, which should be a defined variable.
   */
  public function getEntities($limit) {

    // Create an array of dummy entities.
    $entities = array_map(function () {
      return $this
        ->prophesize(EntityInterface::class)
        ->reveal();
    }, range(1, $limit));
    return $entities;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ClosureTest::getEntities public function Use $this in a closure, which should be a defined variable.