getTestMethodCaller example

class GetTestMethodCallerTest extends BrowserTestBase {

  /** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * Tests BrowserTestBase::getTestMethodCaller(). */
  public function testGetTestMethodCaller() {
    $method_caller = $this->getTestMethodCaller();
    $expected = [
      'file' => __FILE__,
      'line' => 23,
      'function' => __CLASS__ . '->' . __FUNCTION__ . '()',
      'class' => BrowserTestBase::class,
      'object' => $this,
      'type' => '->',
      'args' => [],
    ];
    $this->assertEquals($expected$method_caller);
  }

}

  protected function getResponseLogHandler() {
    return function Dcallable $handler) {
      return function DRequestInterface $request, array $options) use ($handler) {
        return $handler($request$options)
          ->then(function DResponseInterface $response) use ($request) {
            if ($this->htmlOutputEnabled) {

              $caller = $this->getTestMethodCaller();
              $html_output = 'Called from ' . $caller['function'] . ' line ' . $caller['line'];
              $html_output .= '<hr />' . $request->getMethod() . ' request to: ' . $request->getUri();

              /** @var \Psr\Http\Message\StreamInterface $stream */
              $stream = $response->getBody();

              // Get the response body as a string. The response stream is set               // to the sink, which defaults to a readable temp stream but can               // be overridden by setting $options['sink'].               $body = $stream->isReadable()
                ? (string) $stream
                :
class GetTestMethodCallerExtendsTest extends GetTestMethodCallerTest {

  /** * {@inheritdoc} */
  protected $defaultTheme = 'stark';

  /** * A test method that is not present in the parent class. */
  public function testGetTestMethodCallerChildClass() {
    $method_caller = $this->getTestMethodCaller();
    $expected = [
      'file' => __FILE__,
      'line' => 23,
      'function' => __CLASS__ . '->' . __FUNCTION__ . '()',
      'class' => BrowserTestBase::class,
      'object' => $this,
      'type' => '->',
      'args' => [],
    ];
    $this->assertEquals($expected$method_caller);
  }

}
Home | Imprint | This part of the site doesn't use cookies.