Permalink
Browse files

Adding basic test.

  • Loading branch information...
1 parent e3e0128 commit 25573a4f3a1884a658e2ce7206abc9caefffd5fa @davidpersson committed Mar 8, 2011
Showing with 53 additions and 0 deletions.
  1. +16 −0 phpunit.xml
  2. +37 −0 tests/integration/Socket/ConnectTest.php
View
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<phpunit backupGlobals="false"
+ backupStaticAttributes="false"
+ syntaxCheck="false">
+ <testsuites>
+ <testsuite name="PHP">
+ <directory suffix="Test.php">tests/integration</directory>
+ </testsuite>
+ </testsuites>
+ <php>
+ <const name="TEST_EXECUTION" value="true" />
+ <const name="TEST_SERVER_HOST" value="127.0.0.1" />
+ <const name="TEST_SERVER_PORT" value="11301" />
+ </php>
+</phpunit>
@@ -0,0 +1,37 @@
+<?php
+
+require_once 'Socket/Beanstalk.php';
+
+class ConnectTest extends PHPUnit_Framework_TestCase {
+
+ public $subject;
+
+ protected function setUp() {
+ $this->subject = new Socket_Beanstalk(array(
+ 'host' => TEST_SERVER_HOST,
+ 'port' => TEST_SERVER_PORT
+ ));
+ if (!$this->subject->connect()) {
+ $message = 'Need a running beanstalk server at ' . TEST_SERVER_HOST . ':' . TEST_SERVER_PORT;
+ $this->markTestSkipped($message);
+ }
+ }
+
+ public function testConnection() {
+ $this->subject->disconnect();
+
+ $result = $this->subject->connect();
+ $this->assertTrue($result);
+
+ $result = $this->subject->connected;
+ $this->assertTrue($result);
+
+ $result = $this->subject->disconnect();
+ $this->assertTrue($result);
+
+ $result = $this->subject->connected;
+ $this->assertFalse($result);
+ }
+}
+
+?>

0 comments on commit 25573a4

Please sign in to comment.