cvs: pear /Auth/tests TestAuthContainer.php

From: Date: Mon, 28 Jul 2003 22:10:36 +0000
Subject: cvs: pear /Auth/tests TestAuthContainer.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-11793@lists.php.net to get a copy of this message
yavo Mon Jul 28 18:10:36 2003 EDT Modified files: /pear/Auth/tests TestAuthContainer.php Log: Some fixes* Index: pear/Auth/tests/TestAuthContainer.php diff -u pear/Auth/tests/TestAuthContainer.php:1.1 pear/Auth/tests/TestAuthContainer.php:1.2 --- pear/Auth/tests/TestAuthContainer.php:1.1 Sat Jul 19 13:58:15 2003 +++ pear/Auth/tests/TestAuthContainer.php Mon Jul 28 18:10:36 2003 @@ -10,7 +10,7 @@ function TestAuthContainer($name){ $this->PHPUnit_TestCase($name); - $this->file =& $this->getContainer(); + $this->container =& $this->getContainer(); $this->user = 'joe'; $this->pass = 'doe'; $this->opt = 'Very cool user'; @@ -23,13 +23,13 @@ function setUp(){ $opt = $this->getExtraOptions(); // Add the default user to be used for some testing - $this->file->addUser($opt['username'], $opt['passwd']); + $this->container->addUser($opt['username'], $opt['passwd']); } function tearDown(){ $opt = $this->getExtraOptions(); // Remove default user - $this->file->removeUser($opt['username']); + $this->container->removeUser($opt['username']); } function testListUsers(){ @@ -38,9 +38,9 @@ return(false); } - $users = $this->file->listUsers(); - if(AUTH_METHOD_NOT_SUPPORTED == $users){ - $this->fail("This operation is not supported by ".get_class($this)); + $users = $this->container->listUsers(); + if(AUTH_METHOD_NOT_SUPPORTED === $users){ + $this->fail("This operation is not supported by ".get_class($this->container)); return(false); } @@ -55,19 +55,23 @@ return(false); } - $cb = count($this->file->listUsers()); - $res = $this->file->addUser($this->user, $this->pass, $this->opt); - $this->assertTrue(AUTH_METHOD_NOT_SUPPORTED == $res, "This operation is not supported by ".get_class($this)); + $cb = count($this->container->listUsers()); + $res = $this->container->addUser($this->user, $this->pass, $this->opt); + if(AUTH_METHOD_NOT_SUPPORTED === $res){ + $this->fail("This operation is not supported by ".get_class($this->container)); + return(false); + } + (PEAR::isError($res))?$error = $res->getMessage():''; $this->assertTrue(!PEAR::isError($res), 'error:'.$error); - $ca = count($this->file->listUsers()); - $users = $this->file->listUsers(); + $ca = count($this->container->listUsers()); + $users = $this->container->listUsers(); $last_username = $users[$c]['username']; $this->assertTrue( ($cb === $ca-1) , sprintf('Count of users before (%s) and after (%s) does not differ by one', $cb, $ca)); - $this->assertTrue( $this->file->fetchData($this->user, $this->pass) , sprintf('Could not verify with the newly created user %s',$this->user)); + $this->assertTrue( $this->container->fetchData($this->user, $this->pass) , sprintf('Could not verify with the newly created user %s',$this->user)); // Remove the user we just added, assumes removeUser works - $this->file->removeUser($this->user); + $this->container->removeUser($this->user); } function testFetchData(){ @@ -77,8 +81,12 @@ } $opt = $this->getExtraOptions(); - $fetch_res = $this->file->fetchData($opt['username'], $opt['passwd']); - $this->assertTrue(AUTH_METHOD_NOT_SUPPORTED == $fetch_res, "This operation is not supported by ".get_class($this)); + $fetch_res = $this->container->fetchData($opt['username'], $opt['passwd']); + if(AUTH_METHOD_NOT_SUPPORTED === $fetch_res){ + $this->fail("This operation is not supported by ".get_class($this->container)); + return(false); + } + $this->assertTrue($fetch_res,sprintf('Could not verify with the default username (%s) and passwd (%s)', $opt['username'], $opt['passwd'])); } @@ -90,7 +98,7 @@ $opt = $this->getExtraOptions(); $this->assertTrue( - $this->file->fetchData(md5($opt['username']), $opt['passwd']), + $this->container->fetchData(md5($opt['username']), $opt['passwd']), sprintf('This test should fail ... ') ); } @@ -103,11 +111,16 @@ // Add a user to be removed when testing removeUuser method // Assume add user works - $this->file->addUser('for_remove', 'for_remove'); - $cb = count($this->file->listUsers()); - $remove_res = $this->file->removeUser('for_remove'); + $this->container->addUser('for_remove', 'for_remove'); + $cb = count($this->container->listUsers()); + $remove_res = $this->container->removeUser('for_remove'); + if(AUTH_METHOD_NOT_SUPPORTED === $remove_res){ + $this->fail("This operation is not supported by ".get_class($this->container)); + return(false); + } + $this->assertTrue(AUTH_METHOD_NOT_SUPPORTED == $remove_res, "This operation is not supported by ".get_class($this)); - $ca = count($this->file->listUsers()); + $ca = count($this->container->listUsers()); $this->assertTrue($cb === $ca+1, sprintf('Could not remove user "%s", count before:%s count after:%s ', 'for_remove', $cb, $ca)); }

« previous php.pear.cvs (#11793) next »