From d021fd72444dfa560cd08bdd2795c719a8f662ec Mon Sep 17 00:00:00 2001
From: Andrew Hoffmann <andrew.hoffmann@wisc.edu>
Date: Tue, 6 Dec 2016 12:58:18 -0600
Subject: [PATCH] Verify missing attributes are set as false

Switch to static calls of PHPUnit assertion methods
---
 .../PreauthUserDetailsProviderTest.php        | 45 ++++++++++++-------
 1 file changed, 28 insertions(+), 17 deletions(-)

diff --git a/src/test/edu/wisc/doit/uwphps/preauth/PreauthUserDetailsProviderTest.php b/src/test/edu/wisc/doit/uwphps/preauth/PreauthUserDetailsProviderTest.php
index 138d9a9..7e6d7de 100644
--- a/src/test/edu/wisc/doit/uwphps/preauth/PreauthUserDetailsProviderTest.php
+++ b/src/test/edu/wisc/doit/uwphps/preauth/PreauthUserDetailsProviderTest.php
@@ -54,17 +54,17 @@ class PreauthUserDetailsProviderTest extends \PHPUnit_Framework_TestCase
     public function loadsUser()
     {
         $this->setEnvironment($this->environment);
-
         $user = $this->provider->loadUser();
 
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::EPPN], $user->getEppn());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::PVI], $user->getPvi());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::FULL_NAME], $user->getFullName());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::EMAIL], $user->getEmailAddress());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::SOURCE], $user->getSource());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::ISIS_EMPLID], $user->getIsisEmplid());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::FIRST_NAME], $user->getFirstName());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::LAST_NAME], $user->getLastName());
+        static::assertNotNull($user);
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::EPPN], $user->getEppn());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::PVI], $user->getPvi());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::FULL_NAME], $user->getFullName());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::EMAIL], $user->getEmailAddress());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::SOURCE], $user->getSource());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::ISIS_EMPLID], $user->getIsisEmplid());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::FIRST_NAME], $user->getFirstName());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::LAST_NAME], $user->getLastName());
     }
 
     /** @test */
@@ -73,13 +73,24 @@ class PreauthUserDetailsProviderTest extends \PHPUnit_Framework_TestCase
         $this->setEnvironment($this->toHttpHeaders($this->environment));
         $user = $this->providerWithHttp->loadUser();
 
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::EPPN], $user->getEppn());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::PVI], $user->getPvi());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::FULL_NAME], $user->getFullName());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::EMAIL], $user->getEmailAddress());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::SOURCE], $user->getSource());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::ISIS_EMPLID], $user->getIsisEmplid());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::FIRST_NAME], $user->getFirstName());
-        $this->assertEquals($this->environment[PreauthUserDetailsProvider::LAST_NAME], $user->getLastName());
+        static::assertNotNull($user);
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::EPPN], $user->getEppn());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::PVI], $user->getPvi());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::FULL_NAME], $user->getFullName());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::EMAIL], $user->getEmailAddress());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::SOURCE], $user->getSource());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::ISIS_EMPLID], $user->getIsisEmplid());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::FIRST_NAME], $user->getFirstName());
+        static::assertEquals($this->environment[PreauthUserDetailsProvider::LAST_NAME], $user->getLastName());
+    }
+
+    /** @test */
+    public function missingAttributeIsFalse()
+    {
+        $this->setEnvironment($this->environment);
+        $this->removeEnvironmentVariable(PreauthUserDetailsProvider::ISIS_EMPLID);
+        $user = $this->provider->loadUser();
+        static::assertNotNull($user);
+        static::assertFalse($user->getIsisEmplid());
     }
 }
-- 
GitLab