public function NodeRevisionGenerateTest::testExistsNodesContentType in Node Revision Delete 8
Tests the existsNodesContentType() method.
@covers ::existsNodesContentType @dataProvider providerExistsNodesContentType
Parameters
bool $expected: The expected result from calling the function.
string $content_type: Content type machine name.
File
- modules/
node_revision_generate/ tests/ src/ Unit/ NodeRevisionGenerateTest.php, line 326
Class
- NodeRevisionGenerateTest
- Tests the NodeRevisionGenerate class methods.
Namespace
Drupal\Tests\node_revision_generate\UnitCode
public function testExistsNodesContentType($expected, $content_type) {
// StatementInterface mock.
$statement = $this
->createMock('Drupal\\Core\\Database\\StatementInterface');
// StatementInterface::fetchAll mock.
$statement
->expects($this
->any())
->method('fetchField')
->willReturn($expected);
// SelectInterface mock.
$select = $this
->createMock('Drupal\\Core\\Database\\Query\\SelectInterface');
// SelectInterface::execute mock.
$select
->expects($this
->any())
->method('execute')
->willReturn($statement);
// SelectInterface::countQuery mock.
$select
->expects($this
->any())
->method('countQuery')
->willReturn($select);
// SelectInterface::condition mock.
$select
->expects($this
->any())
->method('condition')
->with('type', $content_type)
->willReturn($this
->returnSelf());
// SelectInterface::addField mock.
$select
->expects($this
->any())
->method('addField')
->with('node', 'nid')
->willReturn($this
->returnSelf());
// Mocking select method.
$this->connection
->expects($this
->any())
->method('select')
->with('node')
->willReturn($select);
// Testing the method.
$this
->assertEquals($expected, $this->nodeRevisionGenerate
->existsNodesContentType($content_type));
}