Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\node\Unit\PageCache\DenyNodePreviewTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\node\Unit\PageCache;
|
||||
|
||||
use Drupal\Core\PageCache\ResponsePolicyInterface;
|
||||
use Drupal\node\PageCache\DenyNodePreview;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\node\PageCache\DenyNodePreview
|
||||
* @group node
|
||||
*/
|
||||
class DenyNodePreviewTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The response policy under test.
|
||||
*
|
||||
* @var \Drupal\node\PageCache\DenyNodePreview
|
||||
*/
|
||||
protected $policy;
|
||||
|
||||
/**
|
||||
* A request object.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\Request
|
||||
*/
|
||||
protected $request;
|
||||
|
||||
/**
|
||||
* A response object.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
protected $response;
|
||||
|
||||
/**
|
||||
* The current route match.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RouteMatch|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $routeMatch;
|
||||
|
||||
public function setUp() {
|
||||
$this->routeMatch = $this->getMock('Drupal\Core\Routing\RouteMatchInterface');
|
||||
$this->policy = new DenyNodePreview($this->routeMatch);
|
||||
$this->response = new Response();
|
||||
$this->request = new Request();
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that caching is denied on the node preview route.
|
||||
*
|
||||
* @dataProvider providerPrivateImageStyleDownloadPolicy
|
||||
* @covers ::check
|
||||
*/
|
||||
public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) {
|
||||
$this->routeMatch->expects($this->once())
|
||||
->method('getRouteName')
|
||||
->will($this->returnValue($route_name));
|
||||
|
||||
$actual_result = $this->policy->check($this->response, $this->request);
|
||||
$this->assertSame($expected_result, $actual_result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data and expected results for the test method.
|
||||
*
|
||||
* @return array
|
||||
* Data and expected results.
|
||||
*/
|
||||
public function providerPrivateImageStyleDownloadPolicy() {
|
||||
return [
|
||||
[ResponsePolicyInterface::DENY, 'entity.node.preview'],
|
||||
[NULL, 'some.other.route'],
|
||||
[NULL, NULL],
|
||||
[NULL, FALSE],
|
||||
[NULL, TRUE],
|
||||
[NULL, new \StdClass()],
|
||||
[NULL, [1, 2, 3]],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\node\Unit\Plugin\views\field\NodeBulkFormTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\node\Unit\Plugin\views\field;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\node\Plugin\views\field\NodeBulkForm;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\node\Plugin\views\field\NodeBulkForm
|
||||
* @group node
|
||||
*/
|
||||
class NodeBulkFormTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function tearDown() {
|
||||
parent::tearDown();
|
||||
$container = new ContainerBuilder();
|
||||
\Drupal::setContainer($container);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the constructor assignment of actions.
|
||||
*/
|
||||
public function testConstructor() {
|
||||
$actions = array();
|
||||
|
||||
for ($i = 1; $i <= 2; $i++) {
|
||||
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
|
||||
$action->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('node'));
|
||||
$actions[$i] = $action;
|
||||
}
|
||||
|
||||
$action = $this->getMock('\Drupal\system\ActionConfigEntityInterface');
|
||||
$action->expects($this->any())
|
||||
->method('getType')
|
||||
->will($this->returnValue('user'));
|
||||
$actions[] = $action;
|
||||
|
||||
$entity_storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$entity_storage->expects($this->any())
|
||||
->method('loadMultiple')
|
||||
->will($this->returnValue($actions));
|
||||
|
||||
$entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface');
|
||||
$entity_manager->expects($this->once())
|
||||
->method('getStorage')
|
||||
->with('action')
|
||||
->will($this->returnValue($entity_storage));
|
||||
|
||||
$language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||
|
||||
$views_data = $this->getMockBuilder('Drupal\views\ViewsData')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$views_data->expects($this->any())
|
||||
->method('get')
|
||||
->with('node')
|
||||
->will($this->returnValue(array('table' => array('entity type' => 'node'))));
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('views.views_data', $views_data);
|
||||
$container->set('string_translation', $this->getStringTranslationStub());
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
$storage = $this->getMock('Drupal\views\ViewEntityInterface');
|
||||
$storage->expects($this->any())
|
||||
->method('get')
|
||||
->with('base_table')
|
||||
->will($this->returnValue('node'));
|
||||
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$executable->storage = $storage;
|
||||
|
||||
$display = $this->getMockBuilder('Drupal\views\Plugin\views\display\DisplayPluginBase')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$definition['title'] = '';
|
||||
$options = array();
|
||||
|
||||
$node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $entity_manager, $language_manager);
|
||||
$node_bulk_form->init($executable, $display, $options);
|
||||
|
||||
$this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in a new issue