<commit_before><?php

namespace Doctrine\Tests\ODM\CouchDB\HTTP;

use Doctrine\ODM\CouchDB\HTTP;

class SocketClientTestCase extends \Doctrine\Tests\ODM\CouchDB\CouchDBFunctionalTestCase
{
    /**
     * Return test suite
     *
     * @return PHPUnit_Framework_TestSuite
     */
    public static function suite()
    {
        return new \PHPUnit_Framework_TestSuite( __CLASS__ );
    }

    public function testNoConnectionPossible()
    {
        $db = new HTTP\SocketClient( '127.0.0.1', 12345 );

        try {
            $response = $db->request( 'GET', '/' . $this->getTestDatabase() );
            $this->fail( 'Expected HTTPException.' );
        } catch ( HTTP\HTTPException $e ) {
            // TODO do we have an issue here with OSX, seems to return 61 here
            $this->assertSame(
                'Could not connect to server at 127.0.0.1:12345: \'111: Connection refused\'',
                $e->getMessage()
            );
        }
    }

    public function testCreateDatabase()
    {
        $db = new HTTP\SocketClient();

        // Remove maybe existing database
        try {
            $response = $db->request( 'DELETE', '/' . $this->getTestDatabase() );<commit_msg>make tests work on both OSX and Linux<commit_after><?php

namespace Doctrine\Tests\ODM\CouchDB\HTTP;

use Doctrine\ODM\CouchDB\HTTP;

class SocketClientTestCase extends \Doctrine\Tests\ODM\CouchDB\CouchDBFunctionalTestCase
{
    /**
     * Return test suite
     *
     * @return PHPUnit_Framework_TestSuite
     */
    public static function suite()
    {
        return new \PHPUnit_Framework_TestSuite( __CLASS__ );
    }

    public function testNoConnectionPossible()
    {
        $db = new HTTP\SocketClient( '127.0.0.1', 12345 );

        try {
            $response = $db->request( 'GET', '/' . $this->getTestDatabase() );
            $this->fail( 'Expected HTTPException.' );
        } catch ( HTTP\HTTPException $e ) {
            $this->assertTrue(
                // Message depends on the OS, OSX returns 61, Linux 111
                $e->getMessage() === 'Could not connect to server at 127.0.0.1:12345: \'111: Connection refused\'' ||
                $e->getMessage() === 'Could not connect to server at 127.0.0.1:12345: \'61: Connection refused\''
            );

        }
    }

    public function testCreateDatabase()
    {
        $db = new HTTP\SocketClient();

        // Remove maybe existing database
        try {
            $response = $db->request( 'DELETE', '/' . $this->getTestDatabase() );
{'fraction_non_alphanumeric': 0.12807295796986518, 'fraction_numerical': 0.02775574940523394, 'mean_word_length': 2.13416149068323, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3312890', 'n_tokens_mistral': 787, 'n_tokens_neox': 728, 'n_words': 178}