From 6065342e17f1b2f378d0c7e65d6b94bc2f632034 Mon Sep 17 00:00:00 2001
From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org>
Date: Wed, 8 Jan 2014 12:57:16 +0000
Subject: [PATCH] Revert "Issue #2142989 by fago, stefan.r: Test for
 BundleConstraintValidator."

This reverts commit cb41c8cfcfc5546db7555cae1755894e4d45799d.
---
 .../Constraint/BundleConstraintValidator.php  |  2 +-
 .../Entity/BundleConstraintValidatorTest.php  | 82 -------------------
 2 files changed, 1 insertion(+), 83 deletions(-)
 delete mode 100644 core/modules/system/lib/Drupal/system/Tests/Entity/BundleConstraintValidatorTest.php

diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php
index 196dab96693d..876c1e3729ca 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/BundleConstraintValidator.php
@@ -20,7 +20,7 @@ class BundleConstraintValidator extends ConstraintValidator {
    */
   public function validate($entity, Constraint $constraint) {
     if (!empty($entity) && !in_array($entity->bundle(), $constraint->getBundleOption())) {
-      $this->context->addViolation($constraint->message, array('%bundle' => implode(', ', $constraint->getBundleOption())));
+      $this->context->addViolation($constraint->message, array('%bundle', implode(', ', $constraint->getBundleOption())));
     }
   }
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/BundleConstraintValidatorTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/BundleConstraintValidatorTest.php
deleted file mode 100644
index 54dec8c60cae..000000000000
--- a/core/modules/system/lib/Drupal/system/Tests/Entity/BundleConstraintValidatorTest.php
+++ /dev/null
@@ -1,82 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains Drupal\system\Tests\Entity\BundleConstraintValidatorTest.
- */
-
-namespace Drupal\system\Tests\Entity;
-
-use Drupal\Core\TypedData\DataDefinition;
-use Drupal\simpletest\DrupalUnitTestBase;
-use Drupal\system\Tests\TypedData;
-
-/**
- * Tests validation constraints for BundleConstraintValidator.
- */
-class BundleConstraintValidatorTest extends DrupalUnitTestBase {
-
-  /**
-   * The typed data manager to use.
-   *
-   * @var \Drupal\Core\TypedData\TypedDataManager
-   */
-  protected $typedData;
-
-  public static $modules = array('entity', 'node', 'field', 'text');
-
-  public static function getInfo() {
-    return array(
-      'name' => 'Entity bundle constraint',
-      'description' => 'Tests validation constraints for BundleConstraintValidator.',
-      'group' => 'Validation',
-    );
-  }
-
-  public function setUp() {
-    parent::setUp();
-    $this->typedData = $this->container->get('typed_data_manager');
-  }
-
-  /**
-   * Tests bundle constraint validation.
-   */
-  public function testValidation() {
-    // Test with multiple values.
-    $this->assertValidation(array('foo', 'bar'));
-    // Test with a single string value as well.
-    $this->assertValidation('foo');
-  }
-
-  /**
-   * Executes the BundleConstraintValidator test for a given bundle.
-   *
-   * @param string|array $bundle
-   *   Bundle/bundles to use as constraint option.
-   */
-  protected function assertValidation($bundle) {
-    // Create a typed data definition with a Bundle constraint.
-    $definition = DataDefinition::create('entity_reference')
-      ->addConstraint('Bundle', $bundle);
-
-    // Test the validation.
-    $node = $this->container->get('entity.manager')->getStorageController('node')->create(array('type' => 'foo'));
-
-    $typed_data = $this->typedData->create($definition, $node);
-    $violations = $typed_data->validate();
-    $this->assertEqual($violations->count(), 0, 'Validation passed for correct value.');
-
-    // Test the validation when an invalid value is passed.
-    $page_node = $this->container->get('entity.manager')->getStorageController('node')->create(array('type' => 'baz'));
-
-    $typed_data = $this->typedData->create($definition, $page_node);
-    $violations = $typed_data->validate();
-    $this->assertEqual($violations->count(), 1, 'Validation failed for incorrect value.');
-
-    // Make sure the information provided by a violation is correct.
-    $violation = $violations[0];
-    $this->assertEqual($violation->getMessage(), t('The entity must be of bundle %bundle.', array('%bundle' => implode(', ', (array) $bundle))), 'The message for invalid value is correct.');
-    $this->assertEqual($violation->getRoot(), $typed_data, 'Violation root is correct.');
-    $this->assertEqual($violation->getInvalidValue(), $page_node, 'The invalid value is set correctly in the violation.');
-  }
-}
-- 
GitLab