summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwebchick2014-05-05 15:57:01 (GMT)
committerwebchick2014-05-05 15:57:59 (GMT)
commitf715886fe2809a1943f5bc7c2f7fc804bf918470 (patch)
tree64b673a7a8e8e8a9d3f8af6d6e294b22a1f6796a
parent1299c3afcf6529e31e8f818978459aa2191f67a6 (diff)
Issue #2245727 by alexpott | vijaycs85: Add missing configuration schema in Breakpoint component.
-rw-r--r--.idea/php.xml5
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php14
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php10
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php5
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php4
-rw-r--r--core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php1
-rw-r--r--core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointConfigEntityUnitTest.php13
-rw-r--r--core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointGroupConfigEntityUnitTest.php14
-rw-r--r--core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageAdminUITest.php23
-rw-r--r--core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageFieldDisplayTest.php4
-rw-r--r--core/modules/responsive_image/tests/Drupal/responsive_image/Tests/ResponsiveImageMappingEntityTest.php2
11 files changed, 81 insertions, 14 deletions
diff --git a/.idea/php.xml b/.idea/php.xml
new file mode 100644
index 0000000..e31af55
--- /dev/null
+++ b/.idea/php.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="PhpProjectSharedConfiguration" php_language_level="5.5.0" />
+</project>
+
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php
index 5fa0260..714e44e 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/Breakpoint.php
@@ -107,6 +107,20 @@ class Breakpoint extends ConfigEntityBase implements BreakpointInterface {
/**
* {@inheritdoc}
+ *
+ * @throws \Drupal\breakpoint\InvalidBreakpointNameException
+ * Exception thrown if $values['name'] is empty.
+ */
+ public function __construct(array $values, $entity_type = 'breakpoint') {
+ // Check required properties.
+ if (empty($values['name'])) {
+ throw new InvalidBreakpointNameException('Attempt to create an unnamed breakpoint.');
+ }
+ parent::__construct($values, $entity_type);
+ }
+
+ /**
+ * {@inheritdoc}
*/
public function id() {
// If no ID is specified, build one from the properties that uniquely define
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php
index 595ca76..c2426b7 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Entity/BreakpointGroup.php
@@ -7,6 +7,7 @@
namespace Drupal\breakpoint\Entity;
+use Drupal\breakpoint\InvalidBreakpointNameException;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\breakpoint\BreakpointGroupInterface;
use Drupal\breakpoint\InvalidBreakpointSourceException;
@@ -90,9 +91,16 @@ class BreakpointGroup extends ConfigEntityBase implements BreakpointGroupInterfa
public $sourceType = Breakpoint::SOURCE_TYPE_USER_DEFINED;
/**
- * Overrides Drupal\config\ConfigEntityBase::__construct().
+ * {@inheritdoc}
+ *
+ * @throws \Drupal\breakpoint\InvalidBreakpointNameException
+ * Exception thrown if $values['name'] is empty.
*/
public function __construct(array $values, $entity_type = 'breakpoint_group') {
+ // Check required properties.
+ if (empty($values['name'])) {
+ throw new InvalidBreakpointNameException('Attempt to create an unnamed breakpoint group.');
+ }
parent::__construct($values, $entity_type);
}
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php
index e132280..86f9816 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointAPITest.php
@@ -11,6 +11,7 @@ use Drupal\breakpoint\Entity\Breakpoint;
use Drupal\breakpoint\InvalidBreakpointNameException;
use Drupal\breakpoint\InvalidBreakpointSourceException;
use Drupal\breakpoint\InvalidBreakpointSourceTypeException;
+use Drupal\Component\Utility\Unicode;
/**
* Tests for general breakpoint API functions.
@@ -30,8 +31,10 @@ class BreakpointAPITest extends BreakpointTestBase {
*/
public function testConfigName() {
// Try an invalid sourceType.
+ $label = $this->randomName();
$breakpoint = entity_create('breakpoint', array(
- 'label' => drupal_strtolower($this->randomName()),
+ 'label' => $label,
+ 'name' => Unicode::strtolower($label),
'source' => 'custom_module',
'sourceType' => 'oops',
));
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php
index 4358869..646100a 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointCRUDTest.php
@@ -27,9 +27,11 @@ class BreakpointCRUDTest extends BreakpointTestBase {
*/
public function testBreakpointCRUD() {
// Add a breakpoint with minimum data only.
+ $label = $this->randomName();
$breakpoint = entity_create('breakpoint', array(
- 'label' => drupal_strtolower($this->randomName()),
+ 'label' => $label,
'mediaQuery' => '(min-width: 600px)',
+ 'name' => drupal_strtolower($label),
));
$breakpoint->save();
diff --git a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php
index 7a563f6..52c2ef4 100644
--- a/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php
+++ b/core/modules/breakpoint/lib/Drupal/breakpoint/Tests/BreakpointGroupAPITest.php
@@ -12,6 +12,7 @@ use Drupal\breakpoint\Entity\Breakpoint;
use Drupal\breakpoint\InvalidBreakpointNameException;
use Drupal\breakpoint\InvalidBreakpointSourceException;
use Drupal\breakpoint\InvalidBreakpointSourceTypeException;
+use Drupal\Component\Utility\Unicode;
/**
* Tests for general breakpoint group API functions.
diff --git a/core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointConfigEntityUnitTest.php b/core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointConfigEntityUnitTest.php
index 68ff25a..dc59e9c 100644
--- a/core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointConfigEntityUnitTest.php
+++ b/core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointConfigEntityUnitTest.php
@@ -96,6 +96,7 @@ class BreakpointConfigEntityUnitTest extends UnitTestCase {
*/
public function testCalculateDependenciesModule() {
$values = array(
+ 'name' => 'test',
'source' => 'test_module',
'sourceType' => Breakpoint::SOURCE_TYPE_MODULE,
);
@@ -111,6 +112,7 @@ class BreakpointConfigEntityUnitTest extends UnitTestCase {
*/
public function testCalculateDependenciesTheme() {
$values = array(
+ 'name' => 'test',
'source' => 'test_theme',
'sourceType' => Breakpoint::SOURCE_TYPE_THEME,
);
@@ -121,4 +123,15 @@ class BreakpointConfigEntityUnitTest extends UnitTestCase {
$this->assertContains('test_theme', $dependencies['theme']);
}
+ /**
+ * @expectedException \Drupal\breakpoint\InvalidBreakpointNameException
+ */
+ public function testNameException () {
+ new Breakpoint(array(
+ 'label' => $this->randomName(),
+ 'source' => 'custom_module',
+ 'sourceType' => 'oops',
+ ));
+ }
+
}
diff --git a/core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointGroupConfigEntityUnitTest.php b/core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointGroupConfigEntityUnitTest.php
index 6587e90..4b81a65 100644
--- a/core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointGroupConfigEntityUnitTest.php
+++ b/core/modules/breakpoint/tests/Drupal/breakpoint/Tests/BreakpointGroupConfigEntityUnitTest.php
@@ -8,6 +8,7 @@
namespace Drupal\breakpoint\Tests;
use Drupal\breakpoint\Entity\Breakpoint;
+use Drupal\breakpoint\Entity\BreakpointGroup;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\UnitTestCase;
@@ -109,6 +110,7 @@ class BreakpointGroupConfigEntityUnitTest extends UnitTestCase {
public function testCalculateDependenciesModule() {
$this->setUpEntity(
array(
+ 'name' => 'test',
'source' => 'test_module',
'sourceType' => Breakpoint::SOURCE_TYPE_MODULE,
)
@@ -134,6 +136,7 @@ class BreakpointGroupConfigEntityUnitTest extends UnitTestCase {
public function testCalculateDependenciesTheme() {
$this->setUpEntity(
array(
+ 'name' => 'test',
'source' => 'test_theme',
'sourceType' => Breakpoint::SOURCE_TYPE_THEME,
)
@@ -155,4 +158,15 @@ class BreakpointGroupConfigEntityUnitTest extends UnitTestCase {
$this->assertContains('breakpoint.breakpoint.test', $dependencies['entity']);
}
+ /**
+ * @expectedException \Drupal\breakpoint\InvalidBreakpointNameException
+ */
+ public function testNameException () {
+ new BreakpointGroup(array(
+ 'label' => $this->randomName(),
+ 'source' => 'custom_module',
+ 'sourceType' => 'oops',
+ ));
+ }
+
}
diff --git a/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageAdminUITest.php b/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageAdminUITest.php
index 41e152e..b752a16 100644
--- a/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageAdminUITest.php
+++ b/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageAdminUITest.php
@@ -16,6 +16,13 @@ use Drupal\breakpoint\Entity\Breakpoint;
class ResponsiveImageAdminUITest extends WebTestBase {
/**
+ * The breakpoint group for testing.
+ *
+ * @var \Drupal\breakpoint\Entity\BreakpointGroupInterface
+ */
+ protected $breakpointGroup;
+
+ /**
* Modules to enable.
*
* @var array
@@ -47,8 +54,8 @@ class ResponsiveImageAdminUITest extends WebTestBase {
$this->drupalLogin($this->admin_user);
// Add breakpoint_group and breakpoints.
- $breakpoint_group = entity_create('breakpoint_group', array(
- 'id' => 'atestset',
+ $this->breakpointGroup = entity_create('breakpoint_group', array(
+ 'name' => 'atestset',
'label' => 'A test set',
'sourceType' => Breakpoint::SOURCE_TYPE_USER_DEFINED,
));
@@ -67,9 +74,9 @@ class ResponsiveImageAdminUITest extends WebTestBase {
),
));
$breakpoint->save();
- $breakpoint_group->addBreakpoints(array($breakpoint));
+ $this->breakpointGroup->addBreakpoints(array($breakpoint));
}
- $breakpoint_group->save();
+ $this->breakpointGroup->save();
}
@@ -83,13 +90,13 @@ class ResponsiveImageAdminUITest extends WebTestBase {
// Add a new responsive image mapping, our breakpoint set should be selected.
$this->drupalGet('admin/config/media/responsive-image-mapping/add');
- $this->assertFieldByName('breakpointGroup', 'atestset');
+ $this->assertFieldByName('breakpointGroup', $this->breakpointGroup->id());
// Create a new group.
$edit = array(
'label' => 'Mapping One',
'id' => 'mapping_one',
- 'breakpointGroup' => 'atestset',
+ 'breakpointGroup' => $this->breakpointGroup->id(),
);
$this->drupalPostForm('admin/config/media/responsive-image-mapping/add', $edit, t('Save'));
@@ -103,7 +110,7 @@ class ResponsiveImageAdminUITest extends WebTestBase {
// Edit the group.
$this->drupalGet('admin/config/media/responsive-image-mapping/mapping_one');
$this->assertFieldByName('label', 'Mapping One');
- $this->assertFieldByName('breakpointGroup', 'atestset');
+ $this->assertFieldByName('breakpointGroup', $this->breakpointGroup->id());
// Check if the dropdows are present for the mappings.
$this->assertFieldByName('mappings[custom.user.small][1x]', '');
@@ -116,7 +123,7 @@ class ResponsiveImageAdminUITest extends WebTestBase {
// Save mappings for 1x variant only.
$edit = array(
'label' => 'Mapping One',
- 'breakpointGroup' => 'atestset',
+ 'breakpointGroup' => $this->breakpointGroup->id(),
'mappings[custom.user.small][1x]' => 'thumbnail',
'mappings[custom.user.medium][1x]' => 'medium',
'mappings[custom.user.large][1x]' => 'large',
diff --git a/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageFieldDisplayTest.php b/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageFieldDisplayTest.php
index e7e54a6..5d34845 100644
--- a/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageFieldDisplayTest.php
+++ b/core/modules/responsive_image/lib/Drupal/responsive_image/Tests/ResponsiveImageFieldDisplayTest.php
@@ -60,7 +60,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
// Add breakpoint_group and breakpoints.
$breakpoint_group = entity_create('breakpoint_group', array(
- 'id' => 'atestset',
+ 'name' => 'atestset',
'label' => 'A test set',
'sourceType' => Breakpoint::SOURCE_TYPE_USER_DEFINED,
));
@@ -87,7 +87,7 @@ class ResponsiveImageFieldDisplayTest extends ImageFieldTestBase {
$responsive_image_mapping = entity_create('responsive_image_mapping', array(
'id' => 'mapping_one',
'label' => 'Mapping One',
- 'breakpointGroup' => 'atestset',
+ 'breakpointGroup' => $breakpoint_group->id(),
));
$responsive_image_mapping->save();
$mappings = array();
diff --git a/core/modules/responsive_image/tests/Drupal/responsive_image/Tests/ResponsiveImageMappingEntityTest.php b/core/modules/responsive_image/tests/Drupal/responsive_image/Tests/ResponsiveImageMappingEntityTest.php
index 43ccb05..8565c3b 100644
--- a/core/modules/responsive_image/tests/Drupal/responsive_image/Tests/ResponsiveImageMappingEntityTest.php
+++ b/core/modules/responsive_image/tests/Drupal/responsive_image/Tests/ResponsiveImageMappingEntityTest.php
@@ -99,7 +99,7 @@ class ResponsiveImageMappingEntityTest extends UnitTestCase {
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$this->breakpointGroupId = $this->randomName(9);
- $this->breakpointGroup = $this->getMock('Drupal\breakpoint\Entity\BreakpointGroup', array(), array(array('id' => $this->breakpointGroupId)));
+ $this->breakpointGroup = $this->getMock('Drupal\breakpoint\Entity\BreakpointGroup', array(), array(array('name' => 'test', 'id' => $this->breakpointGroupId)));
$this->breakpointGroupStorage = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface');
$this->breakpointGroupStorage