Open Data Catalog v2.0.0
ServiceTest.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Drupal\Component\DependencyInjection\Container;
6 use Drupal\Core\Config\ConfigFactory;
7 use Drupal\Core\Config\ImmutableConfig;
8 use MockChain\Chain;
10 use PHPUnit\Framework\TestCase;
11 
15 class ServiceTest extends TestCase {
16 
20  public function testAutoLimitOnSqlStatements() {
21  $container = (new Chain($this))
22  ->add(Container::class, "get", ConfigFactory::class)
23  ->add(ConfigFactory::class, "get", ImmutableConfig::class)
24  ->add(ImmutableConfig::class, "get", "100")
25  ->getMock();
26 
27  $service = Service::create($container);
28  $query = $service->getQueryObject("[SELECT * FROM blah];");
29  $this->assertTrue(isset($query->limit));
30  $this->assertEquals($query->limit, 100);
31  }
32 
37  $container = (new Chain($this))
38  ->add(Container::class, "get", ConfigFactory::class)
39  ->add(ConfigFactory::class, "get", ImmutableConfig::class)
40  ->add(ImmutableConfig::class, "get", "100")
41  ->getMock();
42 
43  $service = Service::create($container);
44  $query = $service->getQueryObject("[SELECT COUNT(*) FROM blah];");
45  $this->assertFalse(isset($query->limit));
46  }
47 
48 }
Drupal\Tests\dkan_sql_endpoint
Drupal\Tests\dkan_sql_endpoint\ServiceTest\testAutoLimitOnSqlStatements
testAutoLimitOnSqlStatements()
Definition: ServiceTest.php:20
Drupal\Tests\dkan_sql_endpoint\ServiceTest\testNoAutoLimitOnCountSqlStatements
testNoAutoLimitOnCountSqlStatements()
Definition: ServiceTest.php:36
Drupal\dkan_sql_endpoint\Service
Definition: Service.php:16
Drupal\dkan_sql_endpoint\Service\create
static create(ContainerInterface $container)
Definition: Service.php:24
Drupal\Tests\dkan_sql_endpoint\ServiceTest
Definition: ServiceTest.php:15