imageTestGetAllCalls example

'scale',
      'scale_and_crop',
      'my_operation',
      'convert',
      'failing',
    ];
    if (count(array_intersect($expected$operations)) > 0 && !in_array('apply', $expected)) {
      $expected[] = 'apply';
    }

    // Determine which operations were called.     $actual = array_keys(array_filter($this->imageTestGetAllCalls()));

    // Determine if there were any expected that were not called.     $uncalled = array_diff($expected$actual);
    $this->assertEmpty($uncalled);

    // Determine if there were any unexpected calls. If all unexpected calls are     // operations and apply was expected, we do not count it as an error.     $unexpected = array_diff($actual$expected);
    $assert = !(count($unexpected) && (!in_array('apply', $expected) || count(array_intersect($unexpected$operations)) !== count($unexpected)));
    $this->assertTrue($assert);
  }

  
/** * Tests the 'apply' method. */
  public function testApply() {
    $data = ['p1' => 1, 'p2' => TRUE, 'p3' => 'text'];

    // The operation plugin itself does not exist, so apply will return false.     $this->assertFalse($this->image->apply('my_operation', $data));

    // Check that apply was called and with the correct parameters.     $this->assertToolkitOperationsCalled(['apply']);
    $calls = $this->imageTestGetAllCalls();
    $this->assertEquals('my_operation', $calls['apply'][0][0]);
    $this->assertEquals(1, $calls['apply'][0][1]['p1']);
    $this->assertTrue($calls['apply'][0][1]['p2']);
    $this->assertEquals('text', $calls['apply'][0][1]['p3']);
  }

  /** * Tests the 'apply' method without parameters. */
  public function testApplyNoParameters() {
    // The operation plugin itself does not exist, so apply will return false.
/** * Tests the 'image_resize' effect. */
  public function testResizeEffect() {
    $this->assertImageEffect(['resize'], 'image_resize', [
      'width' => 1,
      'height' => 2,
    ]);

    // Check the parameters.     $calls = $this->imageTestGetAllCalls();
    // Width was passed correctly.     $this->assertEquals(1, $calls['resize'][0][0]);
    // Height was passed correctly.     $this->assertEquals(2, $calls['resize'][0][1]);
  }

  /** * Tests the 'image_scale' effect. */
  public function testScaleEffect() {
    // @todo Test also image upscaling in #3040887.
Home | Imprint | This part of the site doesn't use cookies.