NodeBulkFormTest.php 1.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
<?php

/**
 * @file
 * Contains \Drupal\node\Tests\Plugin\views\field\NodeBulkFormTest.
 */

namespace Drupal\node\Tests\Plugin\views\field;

use Drupal\node\Plugin\views\field\NodeBulkForm;
use Drupal\Tests\UnitTestCase;

/**
 * Tests the node bulk form plugin.
 *
 * @see \Drupal\node\Plugin\views\field\NodeBulkForm
 */
class NodeBulkFormTest extends UnitTestCase {

  public static function getInfo() {
    return array(
      'name' => 'Node: Bulk form',
      'description' => 'Tests the node bulk form plugin.',
      'group' => 'Views module integration',
    );
  }

  /**
   * Tests the constructor assignment of actions.
   */
  public function testConstructor() {
    $actions = array();

    for ($i = 1; $i <= 2; $i++) {
      $action = $this->getMockBuilder('Drupal\system\Plugin\Core\Entity\Action')
        ->disableOriginalConstructor()
        ->getMock();
      $action->expects($this->any())
        ->method('getType')
        ->will($this->returnValue('node'));
      $actions[$i] = $action;
    }

    $action = $this->getMockBuilder('Drupal\system\Plugin\Core\Entity\Action')
      ->disableOriginalConstructor()
      ->getMock();
    $action->expects($this->any())
      ->method('getType')
      ->will($this->returnValue('user'));
    $actions[] = $action;

    $entity_manager = $this->getMockBuilder('Drupal\Core\Entity\EntityManager')
      ->disableOriginalConstructor()
      ->getMock();
    $storage_controller = $this->getMock('Drupal\Core\Entity\EntityStorageControllerInterface');
    $storage_controller->expects($this->any())
      ->method('loadMultiple')
      ->will($this->returnValue($actions));

    $entity_manager->expects($this->any())
      ->method('getStorageController')
      ->with('action')
      ->will($this->returnValue($storage_controller));
    $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', array(), $entity_manager);

    $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form);
  }

}