Open Data Catalog v2.0.0
DatabaseTableFactoryTest.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Drupal\Core\Database\Connection;
6 use MockChain\Chain;
9 use PHPUnit\Framework\TestCase;
10 
14 class DatabaseTableFactoryTest extends TestCase {
15 
19  public function test() {
20 
21  $connection = (new Chain($this))
22  ->add(Connection::class, "blah", NULL)
23  ->getMock();
24 
25  $databaseTable = (new Chain($this))
26  ->add(DatabaseTable::class, "blah", NULL)
27  ->getMock();
28 
29  $factory = $this->getMockBuilder(DatabaseTableFactory::class)
30  ->setConstructorArgs([$connection])
31  ->setMethods(['getDatabaseTable'])
32  ->getMock();
33 
34  $factory->method('getDatabaseTable')->willReturn($databaseTable);
35 
36  $fileStorage = $factory->getInstance('blah');
37  $fileStorage2 = $factory->getInstance('blah');
38  $this->assertEquals($fileStorage, $fileStorage2);
39  }
40 
41 }
Drupal\dkan_harvest\Storage\DatabaseTable
Definition: DatabaseTable.php:11
Drupal\Tests\dkan_harvest\Unit\Storage\DatabaseTableFactoryTest\test
test()
Definition: DatabaseTableFactoryTest.php:19
Drupal\dkan_harvest\Storage\DatabaseTableFactory
Definition: DatabaseTableFactory.php:11
Drupal\Tests\dkan_harvest\Unit\Storage\DatabaseTableFactoryTest
Definition: DatabaseTableFactoryTest.php:14
Drupal\Tests\dkan_harvest\Unit\Storage
Definition: DatabaseTableFactoryTest.php:3