returnArgument example


  public function testGenerateExternal() {
    $this->urlAssembler->expects($this->once())
      ->method('assemble')
      ->with('https://www.drupal.org', ['set_active_class' => TRUE, 'external' => TRUE] + $this->defaultOptions)
      ->will($this->returnArgument(0));

    $this->moduleHandler->expects($this->once())
      ->method('alter')
      ->with('link', $this->isType('array'));

    $this->urlAssembler->expects($this->once())
      ->method('assemble')
      ->with('https://www.drupal.org', ['set_active_class' => TRUE, 'external' => TRUE] + $this->defaultOptions)
      ->willReturnArgument(0);

    $url = Url::fromUri('https://www.drupal.org');
    
protected $unroutedInternal = 'base:robots.txt';

  /** * {@inheritdoc} */
  protected function setUp(): void {
    parent::setUp();

    $this->urlAssembler = $this->createMock('Drupal\Core\Utility\UnroutedUrlAssemblerInterface');
    $this->urlAssembler->expects($this->any())
      ->method('assemble')
      ->will($this->returnArgument(0));

    $this->router = $this->createMock('Drupal\Tests\Core\Routing\TestRouterInterface');
    $container = new ContainerBuilder();
    $container->set('router.no_access_checks', $this->router);
    $container->set('unrouted_url_assembler', $this->urlAssembler);
    \Drupal::setContainer($container);
  }

  /** * Tests the fromUri() method. * * @covers ::fromUri * * @dataProvider providerFromUri */

  public function setupAccessManagerToAllow() {
    $this->accessManager->expects($this->any())
      ->method('check')
      ->willReturn((new AccessResultAllowed())->cachePerPermissions());
  }

  protected function setupStubPathProcessor() {
    $this->pathProcessor->expects($this->any())
      ->method('processInbound')
      ->will($this->returnArgument(0));
  }

}

/** * Helper class for testing purposes only. */
class TestPathBasedBreadcrumbBuilder extends PathBasedBreadcrumbBuilder {

  protected LinkGeneratorInterface $linkGenerator;

  
$image_style = $this->getImageStyleMock($image_effect_id$image_effect);
    $this->assertEquals($image_style->buildUri('public://test.jpeg'), 'public://styles/' . $image_style->id() . '/public/test.jpeg.png');

    // Image style that doesn't change the extension.     $image_effect_id = $this->randomMachineName();
    $image_effect = $this->getMockBuilder('\Drupal\image\ImageEffectBase')
      ->setConstructorArgs([[]$image_effect_id[]$logger])
      ->getMock();
    $image_effect->expects($this->any())
      ->method('getDerivativeExtension')
      ->will($this->returnArgument(0));

    $image_style = $this->getImageStyleMock($image_effect_id$image_effect);
    $this->assertEquals($image_style->buildUri('public://test.jpeg'), 'public://styles/' . $image_style->id() . '/public/test.jpeg');
  }

  /** * @covers ::getPathToken */
  public function testGetPathToken() {
    $logger = $this->getMockBuilder('\Psr\Log\LoggerInterface')->getMock();
    $private_key = $this->randomMachineName();
    

  public function testGetInfoElementPlugin($plugin_class$expected_info) {
    $this->moduleHandler->expects($this->once())
      ->method('alter')
      ->with('element_info', $this->anything())
      ->will($this->returnArgument(0));

    $plugin = $this->createMock($plugin_class);
    $plugin->expects($this->once())
      ->method('getInfo')
      ->willReturn([
        '#theme' => 'page',
      ]);

    $element_info = $this->getMockBuilder('Drupal\Core\Render\ElementInfoManager')
      ->setConstructorArgs([new \ArrayObject()$this->cache, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager])
      ->onlyMethods(['getDefinitions', 'createInstance'])
      
$this->assertFalse($image->isValid());
    $this->assertFalse($image->save());
  }

  /** * Tests \Drupal\Core\Image\Image::scale(). */
  public function testScaleWidth() {
    $this->getTestImageForOperation('Scale');
    $this->toolkitOperation->expects($this->once())
      ->method('execute')
      ->will($this->returnArgument(0));

    $ret = $this->image->scale(44, NULL, FALSE);
    $this->assertEquals(50, $ret['height']);
  }

  /** * Tests \Drupal\Core\Image\Image::scale(). */
  public function testScaleHeight() {
    $this->getTestImageForOperation('Scale');
    $this->toolkitOperation->expects($this->once())
      
Home | Imprint | This part of the site doesn't use cookies.