Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 10470 invoked from network); 19 Apr 2010 23:19:28 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 19 Apr 2010 23:19:28 -0000 Received: (qmail 41591 invoked by uid 500); 19 Apr 2010 23:19:27 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 41530 invoked by uid 500); 19 Apr 2010 23:19:27 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 41522 invoked by uid 99); 19 Apr 2010 23:19:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Apr 2010 23:19:27 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mrtrick@gmail.com designates 74.125.83.52 as permitted sender) Received: from [74.125.83.52] (HELO mail-gw0-f52.google.com) (74.125.83.52) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Apr 2010 23:19:19 +0000 Received: by gwaa20 with SMTP id a20so1948733gwa.11 for ; Mon, 19 Apr 2010 16:18:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=QJ89RHJUNX5MSP0ieX/RVA+ChcgD42mauiEuEZGpxIc=; b=FHcP09QKn9jKpuMjW8uEHzMV/ShrhuFbQKcyALy7VlwHUfsNBeXcl3hXeXmU8LpaOn MNAwBydN/rxTHUmpwAuO913oY7WnlcOFGmVA+Xyn3j04R6TEiPWkZ54yKZN8vuqWikAZ +RN3W1i7V5vCGZV48329DjJtm5bOlNKqrHtlQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=TcHgLdPAepkoVd6lPed1tnjcWbF32P9e01dYXhmQe+R+ih2Id69yaeXwqq4YYhRYOu Zx9/SkIH6zWAzZ8DHfMHyIR8QShiWXl7jxRiDTsiYNQjZ5q1wpEFFjRSkLyd2V9lL+tz YxRlq6eFkPCzDGhWoBjsTr7QU3/dBsQdMLFuI= Received: by 10.101.176.6 with SMTP id d6mr15574869anp.155.1271719134123; Mon, 19 Apr 2010 16:18:54 -0700 (PDT) Received: from [192.168.1.99] ([124.171.57.11]) by mx.google.com with ESMTPS id 30sm50715167anp.11.2010.04.19.16.18.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 19 Apr 2010 16:18:52 -0700 (PDT) Message-ID: <4BCCE4CC.10106@gmail.com> Date: Tue, 20 Apr 2010 09:18:36 +1000 From: Patrick Barnes User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.9) Gecko/20100317 Lightning/1.0b1 Thunderbird/3.0.4 MIME-Version: 1.0 To: user@couchdb.apache.org Subject: Re: Couchdb and PHPUnit References: <4BCBF548.2070104@gmail.com> <4BCC09D6.5000307@gmail.com> <201004191000.17609.thomas@nunninger.info> In-Reply-To: <201004191000.17609.thomas@nunninger.info> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit That does seem to be the way to go about implementing such a system. I will see how I go, and will publish the results if I end up with something that seems reusable. -Patrick On 19/04/2010 6:00 PM, Thomas Nunninger wrote: > Hi, > > Am Montag, 19. April 2010 09:44:22 schrieb Patrick Barnes: >> Partly - I was wondering also if there was something similar to the >> functionality phpunit has for initialising database contents from XML >> files, etc. > > Why don't you use setUpBeforeClass() and tearDownAfterClass()? In my CouchDB > related test cases I have something like this: > > public static function setUpBeforeClass() > { > $couchDb = new myCouchDb( self::getCouchDbUri() ); > $dbName = 'some_test_database'; > > try > { > $couchDb->createDatabase( $dbName ); > } > catch ( Exception $e ) > { > $couchDb->deleteDatabase( $dbName ); > $couchDb->createDatabase( $dbName ); > } > } > > public static function tearDownAfterClass() > { > $couchDb = new myCouchDb( self::getCouchDbUri() ); > $dbName = 'some_test_database'; > $couchDb->deleteDatabase( $dbName ); > } > > HTH > > Thomas > >> >> On 19/04/2010 5:15 PM, David Coallier wrote: >>> On 19 April 2010 07:16, Patrick Barnes wrote: >>>> Has anyone on the list (or elsewhere) written code for phpunit to make >>>> setting up /tearing down couchdb test databases for unit testing easier? >>> >>> I have setup couchdb to be used in unit tests and from the look of >>> your question all you'd have to do is setup the base class that would >>> have a setUp and that would create an instance to the CouchDB >>> databases you have. >>> >>> abstract class TestBaseCouch extends PHPUnit_Framework_TestCase >>> { >>> protected $couch; >>> >>> public function setUp() >>> { >>> $this->couch = new Couch(); >>> } >>> >>> public function tearDown() >>> { >>> unset($this->config); >>> } >>> } >>> >>> class TestyouWantTestCase extends TestBaseCouch >>> { >>> /** >>> * @expectedException Couch_Exception >>> */ >>> public function testExceptionFromCouchClient() >>> { >>> $this->couch->doSomething(); >>> } >>> } >>> >>> >>> Is that what you mean? > > >