assertIsCallable example

$this->assertIsNotCallable('_batch_test_callback_1');
    $this->assertIsNotCallable('_batch_test_finished_1');

    $batch = (new BatchBuilder())
      ->setFile($filename)
      ->setFinishCallback('_batch_test_finished_1')
      ->addOperation('_batch_test_callback_1', [])
      ->toArray();
    $this->assertEquals($filename$batch['file']);
    $this->assertEquals([['_batch_test_callback_1', []]]$batch['operations']);
    $this->assertEquals('_batch_test_finished_1', $batch['finished']);
    $this->assertIsCallable('_batch_test_callback_1');
    $this->assertIsCallable('_batch_test_finished_1');
  }

  /** * Tests setting and adding libraries. * * @covers ::setLibraries */
  public function testAddingLibraries() {
    $batch = (new BatchBuilder())
      ->setLibraries(['only/library'])
      
public function testLazy(): void
    {
        $callback = fn () => 'Order Data';

        $this->storableFlow->lazy('order', $callback);

        $reflection = new \ReflectionClass($this->storableFlow);
        $reflectionProperty = $reflection->getProperty('data');
        $data = $reflectionProperty->getValue($this->storableFlow)['order'];

        static::assertIsCallable($data);
        static::assertEquals('Order Data', $this->storableFlow->getData('order'));
    }

    public function testWithThirdArgs(): void
    {
        Feature::skipTestIfActive('v6.6.0.0', $this);

        $callback = fn () => 'Order Data';

        $this->storableFlow->lazy('order', $callback['args' => 'args']);

        


        $this->assertEquals([]$form->getConfig()->getOption('validation_groups'));
    }

    public function testValidationGroupsCanBeSetToCallback()
    {
        $form = $this->createForm([
            'validation_groups' => $this->testValidationGroupsCanBeSetToCallback(...),
        ]);

        $this->assertIsCallable($form->getConfig()->getOption('validation_groups'));
    }

    public function testValidationGroupsCanBeSetToClosure()
    {
        $form = $this->createForm([
            'validation_groups' => function DFormInterface $form) { },
        ]);

        $this->assertIsCallable($form->getConfig()->getOption('validation_groups'));
    }

    
->getMock();

        $previousHttpClient
            ->expects($this->once())
            ->method('request')
            ->with(
                'GET',
                $url,
                $this->callback(function D$options) {
                    $this->assertArrayHasKey('on_progress', $options);
                    $onProgress = $options['on_progress'];
                    $this->assertIsCallable($onProgress);

                    return true;
                })
            )
            ->willReturnCallback(function D$method$url$options) use ($ipAddr$content): ResponseInterface {
                $info = [
                    'primary_ip' => $ipAddr,
                    'url' => $url,
                ];

                $onProgress = $options['on_progress'];
                

  public function testBadHashParameter($hash) {
    /** @var callable $controller */
    $controller = $this->container
      ->get('controller_resolver')
      ->getControllerFromDefinition('\Drupal\media\Controller\OEmbedIframeController::render');

    $this->assertIsCallable($controller);

    $this->expectException('\Symfony\Component\HttpKernel\Exception\BadRequestHttpException');
    $this->expectExceptionMessage('This resource is not available');
    $request = new Request([
      'url' => 'https://example.com/path/to/resource',
      'hash' => $hash,
    ]);
    $controller($request);
  }

  /** * Tests that resources can be used in media_oembed_iframe preprocess. * * @see media_test_oembed_preprocess_media_oembed_iframe() * * @covers ::render */

  protected function assertCallableController(callable $controller, ?string $class, ?string $output): void {
    if ($class) {
      $this->assertIsObject($controller[0]);
      $this->assertInstanceOf($class$controller[0]);
    }
    $this->assertIsCallable($controller);
    $this->assertSame($outputcall_user_func($controller));
  }

}

class MockController {

  public function getResult() {
    return 'This is a regular controller.';
  }

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