public function InsertImageTest::testStyledImageRotation in Insert 8.2
File
- tests/
src/ FunctionalJavaScript/ InsertImageTest.php, line 202
Class
- InsertImageTest
- Tests Insert module's image insert capability.
Namespace
Drupal\Tests\insert\FunctionalJavascriptCode
public function testStyledImageRotation() {
$fieldName = strtolower($this
->randomMachineName());
$this
->createImageField($fieldName, [
'alt_field' => '0',
]);
$this
->updateInsertSettings($fieldName, [
'styles' => [
'thumbnail' => 'thumbnail',
],
'default' => 'thumbnail',
'rotate' => '1',
]);
$images = $this
->drupalGetTestFiles('image');
$this
->drupalGet('node/add/article');
$page = $this
->getSession()
->getPage();
$page
->attachFileToField('files[' . $fieldName . '_0]', \Drupal::service('file_system')
->realpath($images[0]->uri));
$this
->assertSession()
->waitForField($fieldName . '[0][fids]');
$page
->findButton('Insert')
->click();
$body = $page
->findField('body[0][value]');
$this
->assertTrue(strpos($body
->getValue(), 'width="40"') !== FALSE && strpos($body
->getValue(), 'height="20"') !== FALSE, 'Verified default dimension attributes: ' . $body
->getValue());
$page
->findLink('↺')
->click();
$body
->waitFor(20, function ($element) {
/** @var \Behat\Mink\Element\NodeElement $element */
return strpos($element
->getValue(), 'width="20"') !== FALSE;
});
$this
->assertTrue(strpos($body
->getValue(), 'width="20"') !== FALSE && strpos($body
->getValue(), 'height="40"') !== FALSE, 'Switched dimension attribute values: ' . $body
->getValue());
$page
->findLink('↺')
->click();
$body
->waitFor(20, function ($element) {
/** @var \Behat\Mink\Element\NodeElement $element */
return strpos($element
->getValue(), 'width="40"') !== FALSE;
});
$this
->assertTrue(strpos($body
->getValue(), 'width="40"') !== FALSE && strpos($body
->getValue(), 'height="20"') !== FALSE, 'Switched dimension attribute values again after rotating a second time: ' . $body
->getValue());
}