ArrayHelperTest.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace fphammerle\yii2\auth\clientcert\tests;
  3. use \fphammerle\yii2\auth\clientcert\Authenticator;
  4. class ClientCertAuthTest extends \PHPUnit_Framework_TestCase
  5. {
  6. public function mockApplication()
  7. {
  8. $app = new \yii\web\Application([
  9. 'id' => 'yii2-client-cert-auth-test',
  10. 'basePath' => __DIR__,
  11. // 'vendorPath' => dirname(__DIR__) . '/vendor',
  12. 'components' => [
  13. 'db' => [
  14. 'class' => '\yii\db\Connection',
  15. 'dsn' => 'sqlite::memory:',
  16. ],
  17. 'user' => [
  18. 'identityClass' => models\User::className(),
  19. ],
  20. ],
  21. ]);
  22. (new migrations\CreateUserTable)->up();
  23. return $app;
  24. }
  25. public function testDb()
  26. {
  27. $app = $this->mockApplication();
  28. var_dump($app->db->createCommand('SELECT * FROM user')->queryAll());
  29. $this->assertEquals('bar', Authenticator::foo());
  30. $this->assertNull($app->user->getIdentity());
  31. }
  32. }