Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sbisbee/822817 to your computer and use it in GitHub Desktop.
Save sbisbee/822817 to your computer and use it in GitHub Desktop.
From d7b26202e965fec47cb42fdc5a6113820de2c47b Mon Sep 17 00:00:00 2001
From: Sam Bisbee <sam@sbisbee.com>
Date: Fri, 11 Feb 2011 13:47:05 -0500
Subject: [PATCH] Moving the config check to Sag's constructor, and updating tests.
---
src/Sag.php | 6 +++---
tests/SagConfigurationCheckTest.php | 18 +++++++++---------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/Sag.php b/src/Sag.php
index f8798ed..2a7d360 100644
--- a/src/Sag.php
+++ b/src/Sag.php
@@ -15,11 +15,9 @@
limitations under the License.
*/
-require_once('SagConfigurationCheck.php');
-SagConfigurationCheck::run();
-
require_once('SagException.php');
require_once('SagCouchException.php');
+require_once('SagConfigurationCheck.php');
/**
* The Sag class provides the core functionality for talking to CouchDB.
@@ -64,6 +62,8 @@ class Sag
*/
public function Sag($host = "127.0.0.1", $port = "5984")
{
+ SagConfigurationCheck::run();
+
$this->host = $host;
$this->port = $port;
}
diff --git a/tests/SagConfigurationCheckTest.php b/tests/SagConfigurationCheckTest.php
index 9fe64f9..6cf30a5 100644
--- a/tests/SagConfigurationCheckTest.php
+++ b/tests/SagConfigurationCheckTest.php
@@ -18,6 +18,7 @@
// See the README in tests/ for information on running and writing these tests.
require_once('PHPUnit/Framework.php');
+require_once('../src/Sag.php');
class SagConfigurationCheckTest extends PHPUnit_Framework_TestCase
{
@@ -31,7 +32,6 @@ class SagConfigurationCheckTest extends PHPUnit_Framework_TestCase
// Turn off all error reporting
error_reporting(0);
// SagConfigurationCheck::run() does not generate a PHP Notice!
- require_once('../src/Sag.php');
$this->assertTrue(class_exists('Sag'));
}
@@ -41,7 +41,7 @@ class SagConfigurationCheckTest extends PHPUnit_Framework_TestCase
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// SagConfigurationCheck::run() does not generate a PHP Notice!
- require_once('../src/Sag.php');
+ $s = new Sag();
$this->assertTrue(class_exists('Sag'));
}
@@ -51,7 +51,7 @@ class SagConfigurationCheckTest extends PHPUnit_Framework_TestCase
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
// SagConfigurationCheck::run() does not generate a PHP Notice!
- require_once('../src/Sag.php');
+ $s = new Sag();
$this->assertTrue(class_exists('Sag'));
}
@@ -61,23 +61,23 @@ class SagConfigurationCheckTest extends PHPUnit_Framework_TestCase
// best interoperability and forward compatibility of your code.
error_reporting(E_STRICT);
// SagConfigurationCheck::run() does not generate a PHP Notice!
- require_once('../src/Sag.php');
+ $s = new Sag();
$this->assertTrue(class_exists('Sag'));
}
public function testErrorReportingEAll()
{
- $this->setExpectedException('PHPUnit_Framework_Error_Notice');
+ $this->setExpectedException('PHPUnit_Framework_Error');
// Report all PHP errors
error_reporting(E_ALL);
- require_once('../src/Sag.php');
+ $s = new Sag();
}
public function testErrorReportingNegative1()
{
- $this->setExpectedException('PHPUnit_Framework_Error_Notice');
+ $this->setExpectedException('PHPUnit_Framework_Error');
// Report all PHP errors
error_reporting(-1);
- require_once('../src/Sag.php');
+ $s = new Sag();
}
-}
\ No newline at end of file
+}
--
1.7.0.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment