Commit 3daf4e61 authored by Steven Jones's avatar Steven Jones Committed by Steven Jones
Browse files

Issue #2997593 by Steven Jones: Extend 8.x core tests

parent 2dbadc8a
<?php
namespace Drupal\imageapi_optimize\Tests;
/**
* Tests creation, deletion, and editing of image styles and effects.
*
* @group image
*/
class FileMoveTest extends \Drupal\Tests\image\Functional\FileMoveTest {
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\FileMoveTest as OriginalFileMoveTest;
/**
* Tests the file move function for images and image styles.
*
* @group imageapi_optimize
*/
class FileMoveTest extends OriginalFileMoveTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageAdminStylesTest as OriginalImageAdminStylesTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
*
* @group image
* @group imageapi_optimize
*/
class ImageAdminStylesTest extends OriginalImageAdminStylesTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageDimensionsTest as OriginalImageDimensionsTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
* Tests that images have correct dimensions when styled.
*
* @group image
* @group imageapi_optimize
*/
class ImageDimensionsTest extends OriginalImageDimensionsTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageEffectsTest as OriginalImageEffectsTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
* Tests that the image effects pass parameters to the toolkit correctly.
*
* @group image
* @group imageapi_optimize
*/
class ImageEffectsTest extends OriginalImageEffectsTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageFieldDefaultImagesTest as OriginalImageFieldDefaultImagesTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
* Tests setting up default images both to the field and field storage.
*
* @group image
* @group imageapi_optimize
*/
class ImageFieldDefaultImagesTest extends OriginalImageFieldDefaultImagesTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageFieldDisplayTest as OriginalImageFieldDisplayTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
* Tests the display of image fields.
*
* @group image
* @group imageapi_optimize
*/
class ImageFieldDisplayTest extends OriginalImageFieldDisplayTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageFieldValidateTest as OriginalImageFieldValidateTest;
/**
* Tests validation functions such as min/max resolution.
*
* @group image
* @group imageapi_optimize
*/
class ImageFieldValidateTest extends OriginalImageFieldValidateTest {
public static $modules = ['node', 'image', 'field_ui', 'image_module_test', 'imageapi_optimize'];
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageFieldWidgetTest as OriginalImageFieldWidgetTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
* Tests the image field widget.
*
* @group image
* @group imageapi_optimize
*/
class ImageFieldWidgetTest extends OriginalImageFieldWidgetTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageOnTranslatedEntityTest as OriginalImageOnTranslatedEntityTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
* Uploads images to translated nodes.
*
* @group image
* @group imageapi_optimize
*/
class ImageOnTranslatedEntityTest extends OriginalImageOnTranslatedEntityTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageStyleDeleteTest as OriginalImageStyleDeleteTest;
/**
* Tests image style deletion using the UI.
*
* @group image
* @group imageapi_optimize
*/
class ImageStyleDeleteTest extends OriginalImageStyleDeleteTest {
public static $modules = ['node', 'image', 'field_ui', 'image_module_test', 'imageapi_optimize'];
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageStyleFlushTest as OriginalImageStyleFlushTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
* Tests flushing of image styles.
*
* @group image
* @group imageapi_optimize
*/
class ImageStyleFlushTest extends OriginalImageStyleFlushTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\ImageStylesPathAndUrlTest as OriginalImageStylesPathAndUrlTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
* Tests the functions for generating paths and URLs for image styles.
*
* @group image
* @group imageapi_optimize
*/
class ImageStylesPathAndUrlTest extends OriginalImageStylesPathAndUrlTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\Tests\imageapi_optimize\Functional;
use Drupal\Tests\image\Functional\QuickEditImageControllerTest as OriginalQuickEditImageControllerTest;
/**
* Tests the endpoints used by the "image" in-place editor.
*
* @group imageapi_optimize
*/
class QuickEditImageControllerTest extends OriginalQuickEditImageControllerTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\Tests\imageapi_optimize\Functional\Update;
use Drupal\Tests\image\Functional\Update\ImageUpdateTest as OriginalImageUpdateTest;
/**
* Tests Image update path.
*
* @group imageapi_optimize
*/
class ImageUpdateTest extends OriginalImageUpdateTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\FunctionalJavascript;
use Drupal\Tests\image\FunctionalJavascript\ImageAdminStylesTest as OriginalImageAdminStylesTest;
/**
* Tests creation, deletion, and editing of image styles and effects.
*
* @group image
* @group imageapi_optimize
*/
class ImageAdminStylesTest extends OriginalImageAdminStylesTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\imageapi_optimize\Tests;
namespace Drupal\Tests\imageapi_optimize\FunctionalJavascript;
use Drupal\Tests\image\FunctionalJavascript\ImageFieldValidateTest as OriginalImageFieldValidateTest;
/**
* Tests validation functions such as min/max resolution.
*
* @group image
* @group imageapi_optimize
*/
class ImageFieldValidateTest extends OriginalImageFieldValidateTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
<?php
namespace Drupal\Tests\imageapi_optimize\FunctionalJavascript;
use Drupal\Tests\image\FunctionalJavascript\QuickEditImageTest as OriginalQuickEditImageTest;
/**
* Tests the JavaScript functionality of the "image" in-place editor.
*
* @group imageapi_optimize
*/
class QuickEditImageTest extends OriginalQuickEditImageTest {
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
......@@ -2,101 +2,18 @@
namespace Drupal\Tests\imageapi_optimize\Kernel;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Tests\field\Kernel\FieldKernelTestBase;
use Drupal\Tests\image\Kernel\ImageFormatterTest as OriginalImageFormatterTest;
/**
* Tests the image field rendering using entity fields of the image field type.
*
* @group image
* @group imageapi_optimize
*/
class ImageFormatterTest extends FieldKernelTestBase {
class ImageFormatterTest extends OriginalImageFormatterTest {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['file', 'image', 'imageapi_optimize'];
/**
* @var string
*/
protected $entityType;
/**
* @var string
*/
protected $bundle;
/**
* @var string
*/
protected $fieldName;
/**
* @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface
*/
protected $display;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(['field']);
$this->installEntitySchema('entity_test');
$this->installEntitySchema('file');
$this->installSchema('file', ['file_usage']);
$this->entityType = 'entity_test';
$this->bundle = $this->entityType;
$this->fieldName = Unicode::strtolower($this->randomMachineName());
FieldStorageConfig::create([
'entity_type' => $this->entityType,
'field_name' => $this->fieldName,
'type' => 'image',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
])->save();
FieldConfig::create([
'entity_type' => $this->entityType,
'field_name' => $this->fieldName,
'bundle' => $this->bundle,
'settings' => [
'file_extensions' => 'jpg',
],
])->save();
$this->display = entity_get_display($this->entityType, $this->bundle, 'default')
->setComponent($this->fieldName, [
'type' => 'image',
'label' => 'hidden',
]);
$this->display->save();
}
/**
* Tests the cache tags from image formatters.
*/
public function testImageFormatterCacheTags() {
// Create a test entity with the image field set.
$entity = EntityTest::create([
'name' => $this->randomMachineName(),
]);
$entity->{$this->fieldName}->generateSampleItems(2);
$entity->save();
// Generate the render array to verify if the cache tags are as expected.
$build = $this->display->build($entity);
$this->assertEquals($entity->{$this->fieldName}[0]->entity->getCacheTags(), $build[$this->fieldName][0]['#cache']['tags'], 'First image cache tags is as expected');
$this->assertEquals($entity->{$this->fieldName}[1]->entity->getCacheTags(), $build[$this->fieldName][1]['#cache']['tags'], 'Second image cache tags is as expected');
}
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
......@@ -2,45 +2,18 @@
namespace Drupal\Tests\imageapi_optimize\Kernel;
use Drupal\image\Entity\ImageStyle;
use Drupal\KernelTests\KernelTestBase;
use Drupal\Tests\image\Kernel\ImageImportTest as OriginalImageImportTest;
/**
* Tests config import for Image styles.
*
* @group image
* @group imageapi_optimize
*/
class ImageImportTest extends KernelTestBase {
class ImageImportTest extends OriginalImageImportTest {
/**
* {@inheritdoc}
*/
public static $modules = ['system', 'image', 'image_module_test', 'imageapi_optimize'];
/**
* Tests importing image styles.
*/
public function testImport() {
$style = ImageStyle::create([
'name' => 'test',
]);
$style->addImageEffect(['id' => 'image_module_test_null']);
$style->addImageEffect(['id' => 'image_module_test_null']);
$style->save();
$this->assertEqual(count($style->getEffects()), 2);
$uuid = \Drupal::service('uuid')->generate();
$style->set('effects', [
$uuid => [
'id' => 'image_module_test_null',
],
]);
$style->save();
$style = ImageStyle::load('test');
$this->assertEqual(count($style->getEffects()), 1);
}
/**
* {@inheritdoc}
*/
public static $modules = ['imageapi_optimize'];
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment