ArrayHelperTest.php 933 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. use fphammerle\yii2\ClientCertAuth;
  3. class ClientCertAuthTest extends \PHPUnit_Framework_TestCase
  4. {
  5. public function mockApplication()
  6. {
  7. return new \yii\web\Application([
  8. 'id' => 'yii2-client-cert-auth-test',
  9. 'basePath' => __DIR__,
  10. // 'vendorPath' => dirname(__DIR__) . '/vendor',
  11. 'components' => [
  12. 'db' => [
  13. 'class' => '\yii\db\Connection',
  14. 'dsn' => 'sqlite::memory:',
  15. ],
  16. ],
  17. ]);
  18. }
  19. public function testDb()
  20. {
  21. $app = $this->mockApplication();
  22. $app->db->createCommand('CREATE TABLE test ( x INT )')->execute();
  23. $app->db->createCommand('INSERT INTO test (x) VALUES (1), (2), (4)')->execute();
  24. var_dump($app->db->createCommand('SELECT * FROM test')->queryAll());
  25. $this->assertEquals('bar', ClientCertAuth::foo());
  26. }
  27. }