Skip to content

Commit

Permalink
* add basic unittests
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/File_HtAccess/trunk@224529 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Mika Tuupola committed Dec 7, 2006
1 parent a5e74b4 commit 36007db
Show file tree
Hide file tree
Showing 7 changed files with 229 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/01validuser.phpt
@@ -0,0 +1,52 @@
--TEST--
File_HtAccess::load()
--SKIPIF--
<?php
/* first one for cvs */
if (@include(dirname(__FILE__)."/../HtAccess.php")) {
$status = '';
} else if (@include('DB/HtAccess.php')) {
$status = '';
} else {
$status = 'skip';
}
print $status;
?>
--FILE--
<?php
/* first one for cvs */
if (@include(dirname(__FILE__)."/../HtAccess.php")) {
$status = '';
} else if (@include('DB/HtAccess.php')) {
$status = '';
} else {
$status = 'skip';
}
print $status;

$fh = new File_HtAccess('htaccess01');
$fh->load();
print_r($fh);
?>
--GET--
--POST--
--EXPECT--
file_htaccess Object
(
[file] => htaccess01
[authname] => "Protected"
[authtype] => Basic
[authuserfile] => /usr/local/apache/conf/users.dat
[authgroupfile] =>
[authdigestfile] =>
[authdigestgroupfile] =>
[require] => Array
(
[0] => valid-user
)

[additional] => Array
(
)

)
55 changes: 55 additions & 0 deletions tests/02user.phpt
@@ -0,0 +1,55 @@
--TEST--
File_HtAccess::load()
--SKIPIF--
<?php
/* first one for cvs */
if (@include(dirname(__FILE__)."/../HtAccess.php")) {
$status = '';
} else if (@include('DB/HtAccess.php')) {
$status = '';
} else {
$status = 'skip';
}
print $status;
?>
--FILE--
<?php
/* first one for cvs */
if (@include(dirname(__FILE__)."/../HtAccess.php")) {
$status = '';
} else if (@include('DB/HtAccess.php')) {
$status = '';
} else {
$status = 'skip';
}
print $status;

$fh = new File_HtAccess('htaccess02');
$fh->load();
print_r($fh);
?>
--GET--
--POST--
--EXPECT--
file_htaccess Object
(
[file] => htaccess02
[authname] => "Protected"
[authtype] => Basic
[authuserfile] => /usr/local/apache/conf/users.dat
[authgroupfile] =>
[authdigestfile] =>
[authdigestgroupfile] =>
[require] => Array
(
[0] => user
[1] => tuupola
[2] => laane
[3] => viemero
)

[additional] => Array
(
)

)
55 changes: 55 additions & 0 deletions tests/03usermultiline.phpt
@@ -0,0 +1,55 @@
--TEST--
File_HtAccess::load()
--SKIPIF--
<?php
/* first one for cvs */
if (@include(dirname(__FILE__)."/../HtAccess.php")) {
$status = '';
} else if (@include('DB/HtAccess.php')) {
$status = '';
} else {
$status = 'skip';
}
print $status;
?>
--FILE--
<?php
/* first one for cvs */
if (@include(dirname(__FILE__)."/../HtAccess.php")) {
$status = '';
} else if (@include('DB/HtAccess.php')) {
$status = '';
} else {
$status = 'skip';
}
print $status;

$fh = new File_HtAccess('htaccess03');
$fh->load();
print_r($fh);
?>
--GET--
--POST--
--EXPECT--
file_htaccess Object
(
[file] => htaccess03
[authname] => "Protected"
[authtype] => Basic
[authuserfile] => /usr/local/apache/conf/users.dat
[authgroupfile] =>
[authdigestfile] =>
[authdigestgroupfile] =>
[require] => Array
(
[0] => user
[1] => tuupola
[2] => laane
[3] => viemero
)

[additional] => Array
(
)

)
53 changes: 53 additions & 0 deletions tests/04getcontent.phpt
@@ -0,0 +1,53 @@
--TEST--
File_HtAccess::getContent()
--SKIPIF--
<?php
/* first one for cvs */
if (@include(dirname(__FILE__)."/../HtAccess.php")) {
$status = '';
} else if (@include('DB/HtAccess.php')) {
$status = '';
} else {
$status = 'skip';
}
print $status;
?>
--FILE--
<?php
/* first one for cvs */
if (@include(dirname(__FILE__)."/../HtAccess.php")) {
$status = '';
} else if (@include('DB/HtAccess.php')) {
$status = '';
} else {
$status = 'skip';
}
print $status;

$fh = new File_HtAccess('htaccess01');
$fh->load();
print $fh->getContent();
$fh = new File_HtAccess('htaccess02');
$fh->load();
print $fh->getContent();
$fh = new File_HtAccess('htaccess03');
$fh->load();
print $fh->getContent();
?>
--GET--
--POST--
--EXPECT--
AuthName "Protected"
AuthType Basic
AuthUserFile /usr/local/apache/conf/users.dat
Require valid-user

AuthName "Protected"
AuthType Basic
AuthUserFile /usr/local/apache/conf/users.dat
Require user tuupola laane viemero

AuthName "Protected"
AuthType Basic
AuthUserFile /usr/local/apache/conf/users.dat
Require user tuupola laane viemero
4 changes: 4 additions & 0 deletions tests/htaccess01
@@ -0,0 +1,4 @@
AuthName "Protected"
AuthType Basic
AuthUserFile /usr/local/apache/conf/users.dat
require valid-user
4 changes: 4 additions & 0 deletions tests/htaccess02
@@ -0,0 +1,4 @@
AuthName "Protected"
AuthType Basic
AuthUserFile /usr/local/apache/conf/users.dat
require user tuupola laane viemero
6 changes: 6 additions & 0 deletions tests/htaccess03
@@ -0,0 +1,6 @@
AuthName "Protected"
AuthType Basic
AuthUserFile /usr/local/apache/conf/users.dat
require user tuupola
require user laane
require user viemero

0 comments on commit 36007db

Please sign in to comment.