Prechádzať zdrojové kódy

Subject tests: refactored

Fabian Peter Hammerle 8 rokov pred
rodič
commit
e226d59ee5
2 zmenil súbory, kde vykonal 11 pridanie a 9 odobranie
  1. 5 5
      Subject.php
  2. 6 4
      tests/SubjectTest.php

+ 5 - 5
Subject.php

@@ -28,11 +28,11 @@ class Subject extends \yii\db\ActiveRecord
     //     return $this->identity_id;
     // }
 
-    // public static function getIdentityClass()
-    // {
-    //     return \Yii::$app->user->identityClass;
-    // }
-    //
+    public static function getIdentityClass()
+    {
+        return \Yii::$app->user->identityClass;
+    }
+
     // public function getIdentity()
     // {
     //     return $this->hasOne(self::getIdentityClass(), ['id' => 'identity_id']);

+ 6 - 4
tests/SubjectTest.php

@@ -8,10 +8,14 @@ use \fphammerle\yii2\auth\clientcert\migrations;
 
 class SubjectTest extends TestCase
 {
-    public function testCreateModel()
+    protected function setUp()
     {
-        $app = $this->mockApplication();
+        $this->mockApplication();
         (new migrations\CreateSubjectTable)->up();
+    }
+
+    public function testCreateModel()
+    {
         (new Subject('CN=Alice,C=AT'))->save();
         (new Subject('CN=Alice,O=Office,C=AT'))->save();
         (new Subject('CN=Bob,C=AT'))->save();
@@ -32,8 +36,6 @@ class SubjectTest extends TestCase
 
     public function testDNUnique()
     {
-        $app = $this->mockApplication();
-        (new migrations\CreateSubjectTable)->up();
         $this->assertTrue((new Subject('CN=Alice,C=AT'))->save());
         $this->assertTrue((new Subject('CN=Bob,C=AT'))->save());
         $dup = new Subject('CN=Alice,C=AT');