Kaynağa Gözat

added base for test cases

Fabian Peter Hammerle 8 yıl önce
ebeveyn
işleme
c070d10c5d
2 değiştirilmiş dosya ile 30 ekleme ve 25 silme
  1. 28 0
      tests/TestCase.php
  2. 2 25
      tests/UserTest.php

+ 28 - 0
tests/TestCase.php

@@ -0,0 +1,28 @@
+<?php
+
+namespace fphammerle\yii2\auth\clientcert\tests;
+
+abstract class TestCase extends \PHPUnit_Framework_TestCase
+{
+    public function mockApplication()
+    {
+        $app = new \yii\web\Application([
+            'id' => 'yii2-client-cert-auth-test',
+            'basePath' => __DIR__,
+            // 'vendorPath' => dirname(__DIR__) . '/vendor',
+            'components' => [
+                'db' => [
+                    'class' => '\yii\db\Connection',
+                    'dsn' => 'sqlite::memory:',
+                ],
+                'user' => [
+                    'identityClass' => models\User::className(),
+                ],
+            ],
+        ]);
+        $this->assertEquals([], $app->db->getSchema()->getTableNames());
+        (new migrations\CreateUserTable)->up();
+        $this->assertNull($app->user->getIdentity());
+        return $app;
+    }
+}

+ 2 - 25
tests/ArrayHelperTest.php → tests/UserTest.php

@@ -3,33 +3,10 @@
 namespace fphammerle\yii2\auth\clientcert\tests;
 
 use \fphammerle\helpers\ArrayHelper;
-use \fphammerle\yii2\auth\clientcert\Authenticator;
 
-class ClientCertAuthTest extends \PHPUnit_Framework_TestCase
+class UserTest extends TestCase
 {
-    public function mockApplication()
-    {
-        $app = new \yii\web\Application([
-            'id' => 'yii2-client-cert-auth-test',
-            'basePath' => __DIR__,
-            // 'vendorPath' => dirname(__DIR__) . '/vendor',
-            'components' => [
-                'db' => [
-                    'class' => '\yii\db\Connection',
-                    'dsn' => 'sqlite::memory:',
-                ],
-                'user' => [
-                    'identityClass' => models\User::className(),
-                ],
-            ],
-        ]);
-        $this->assertEquals([], $app->db->getSchema()->getTableNames());
-        (new migrations\CreateUserTable)->up();
-        $this->assertNull($app->user->getIdentity());
-        return $app;
-    }
-
-    public function testCreateUser()
+    public function testCreateModel()
     {
         $app = $this->mockApplication();
         (new models\User('a'))->save();