From de97c0711f26b41cb4b1cd125c272fa6b66f4e9b Mon Sep 17 00:00:00 2001
From: James Gilliland <jgilliland@apqc.org>
Date: Mon, 28 Apr 2014 22:20:31 -0500
Subject: [PATCH] Use a native stub for AjaxCommand test.

---
 .../Drupal/Tests/Core/Ajax/AjaxCommandsTest.php    | 52 ++++++++--------------
 1 file changed, 18 insertions(+), 34 deletions(-)

diff --git a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
index 0384148..96798ca 100644
--- a/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
+++ b/core/tests/Drupal/Tests/Core/Ajax/AjaxCommandsTest.php
@@ -24,8 +24,6 @@
 use Drupal\Core\Ajax\ReplaceCommand;
 use Drupal\Core\Ajax\RestripeCommand;
 use Drupal\Core\Ajax\SettingsCommand;
-use Drupal\Core\Ajax\OpenDialogCommand;
-use Drupal\Core\Ajax\OpenModalDialogCommand;
 use Drupal\Core\Ajax\CloseDialogCommand;
 use Drupal\Core\Ajax\CloseModalDialogCommand;
 use Drupal\Core\Ajax\SetDialogOptionCommand;
@@ -308,10 +306,15 @@ public function testSettingsCommand() {
    * Tests that OpenDialogCommand objects can be constructed and rendered.
    */
   public function testOpenDialogCommand() {
-    $command = new TestOpenDialogCommand('#some-dialog', 'Title', '<p>Text!</p>', array(
-      'url' => FALSE,
-      'width' => 500,
-    ));
+    $command = $this->getMockBuilder('Drupal\Core\Ajax\OpenDialogCommand')
+      ->setConstructorArgs(array(
+        '#some-dialog', 'Title', '<p>Text!</p>', array(
+          'url' => FALSE,
+          'width' => 500,
+        )
+      ))
+      ->setMethods(array('drupalAttachLibrary'))
+      ->getMock();
 
     $expected = array(
       'command' => 'openDialog',
@@ -332,10 +335,15 @@ public function testOpenDialogCommand() {
    * Tests that OpenModalDialogCommand objects can be constructed and rendered.
    */
   public function testOpenModalDialogCommand() {
-    $command = new TestOpenModalDialogCommand('Title', '<p>Text!</p>', array(
-      'url' => 'example',
-      'width' => 500,
-    ));
+    $command = $this->getMockBuilder('Drupal\Core\Ajax\OpenModalDialogCommand')
+      ->setConstructorArgs(array(
+        'Title', '<p>Text!</p>', array(
+          'url' => 'example',
+          'width' => 500,
+        )
+      ))
+      ->setMethods(array('drupalAttachLibrary'))
+      ->getMock();
 
     $expected = array(
       'command' => 'openDialog',
@@ -424,27 +432,3 @@ public function testRedirectCommand() {
   }
 
 }
-
-/**
- * Wraps OpenModalDialogCommand::drupalAttachLibrary().
- *
- * {@inheritdoc}
- */
-class TestOpenModalDialogCommand extends OpenModalDialogCommand {
-
-  protected function drupalAttachLibrary($name) {
-  }
-
-}
-
-/**
- * Wraps OpenDialogCommand::drupalAttachLibrary().
- *
- * {@inheritdoc}
- */
-class TestOpenDialogCommand extends OpenDialogCommand {
-
-  protected function drupalAttachLibrary($name) {
-  }
-
-}
-- 
1.9.1

