Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell committed Nov 8, 2014
1 parent 4af42fe commit 4d34b29
Show file tree
Hide file tree
Showing 21 changed files with 277 additions and 283 deletions.
2 changes: 1 addition & 1 deletion phpunit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
include './vendor/autoload.php';

// Remove when fix is merged.
Mockery::getConfiguration()->setInternalClassMethodParamMap('MongoCollection', "aggregate", array('$pipeline', '$op = NULL', '$third = NULL'));
Mockery::getConfiguration()->setInternalClassMethodParamMap('MongoCollection', "aggregate", array('$pipeline', '$op = NULL', '$third = NULL'));
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener" file="./vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php"></listener>
</listeners>
</phpunit>
</phpunit>
6 changes: 3 additions & 3 deletions src/League/Monga.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
namespace League;

use League\Monga\Connection;
use MongoId;
use MongoBinData;
use MongoCode;
use MongoDate;
use MongoDB;
use MongoDate;
use MongoId;
use MongoRegex;
use MongoBinData;

class Monga
{
Expand Down
2 changes: 1 addition & 1 deletion src/League/Monga/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

namespace League\Monga;

use MongoCollection;
use Closure;
use MongoCollection;

class Collection
{
Expand Down
4 changes: 4 additions & 0 deletions src/League/Monga/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ public function connect()
{
if ($this->connection->connect()) {
$this->connected = true;

return true;
}

return false;
}

Expand All @@ -97,8 +99,10 @@ public function disconnect()
{
if ($this->connection->close()) {
$this->connected = false;

return true;
}

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/League/Monga/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

namespace League\Monga;

use MongoDB;
use MongoCode;
use MongoDB;
use MongoDBRef;

class Database
Expand Down
1 change: 0 additions & 1 deletion src/League/Monga/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public function extract($name, $destination = null)
}

return (bool) $this->collection->remove(array('_id' => $file->file['_id']));

}

/**
Expand Down
1 change: 0 additions & 1 deletion src/League/Monga/Query/Projection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

class Projection extends Computer
{

/**
* Specifies a field to be included
*
Expand Down
6 changes: 3 additions & 3 deletions src/League/Monga/Query/Where.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
namespace League\Monga\Query;

use Closure;
use MongoRegex;
use MongoId;
use MongoRegex;

class Where extends Builder
{
Expand Down Expand Up @@ -154,7 +154,7 @@ protected function formatWhere($type, $field, $statement = null)
$lastAndClause = array(
'$and' => array(
$lastAndClause,
array($field => $statement)
array($field => $statement),
),
);
}
Expand Down Expand Up @@ -1042,7 +1042,7 @@ public function getWhere()
* Resolves a string data type to its integer counterpart
*
* @param string|int $type data type
* @return int The data type's integer
* @return int The data type's integer
*/
public function resolveType($type)
{
Expand Down
24 changes: 12 additions & 12 deletions tests/CollectionTests.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use League\Monga;
use League\Monga\Collection;
use League\Monga\Database;
use League\Monga;
use Mockery as m;

class CollectionTests extends PHPUnit_Framework_TestCase
Expand All @@ -13,7 +13,7 @@ class CollectionTests extends PHPUnit_Framework_TestCase

public function setUp()
{
if ( ! $this->connection) {
if (! $this->connection) {
$this->connection = Monga::connection();
}

Expand Down Expand Up @@ -61,8 +61,8 @@ public function testCount()
}

/**
* @expectedException InvalidArgumentException
*/
* @expectedException InvalidArgumentException
*/
public function testCountException()
{
$this->collection->count(false);
Expand Down Expand Up @@ -127,10 +127,10 @@ public function testRemoveWhere()
public function testRemoveWhereClosure()
{
$closure = function ($query) {
$query->where('name' ,'Frank');
$query->where('name', 'Frank');
};
$closure2 = function ($query) {
$query->where('name' ,'Bert');
$query->where('name', 'Bert');
};
$this->collection->getCollection()->insert(array('name' => 'Frank'));
$this->assertEquals(1, $this->collection->count());
Expand All @@ -143,8 +143,8 @@ public function testRemoveWhereClosure()
}

/**
* @expectedException InvalidArgumentException
*/
* @expectedException InvalidArgumentException
*/
public function testInvalidRemove()
{
$this->collection->remove(false);
Expand Down Expand Up @@ -276,8 +276,8 @@ public function testFindOneWithPostFindActionWithResult()
}

/**
* @expectedException InvalidArgumentException
*/
* @expectedException InvalidArgumentException
*/
public function testInvalidFind()
{
$this->collection->find(false);
Expand Down Expand Up @@ -363,8 +363,8 @@ public function testUpdateClosure()
}

/**
* @expectedException InvalidArgumentException
*/
* @expectedException InvalidArgumentException
*/
public function testInvalidUpdate()
{
$result = $this->collection->update(false);
Expand Down
10 changes: 1 addition & 9 deletions tests/ConnectionTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ConnectionTests extends PHPUnit_Framework_TestCase

public function setUp()
{
if ( ! $this->connection) {
if (! $this->connection) {
$this->connection = new Connection(null, array(
'connect' => true,
));
Expand All @@ -33,7 +33,6 @@ public function testDisconnect()
$this->assertFalse($this->connection->isConnected());
}


public function testReconnectonnect()
{
$this->connection->disconnect();
Expand All @@ -44,7 +43,6 @@ public function testReconnectonnect()
$this->assertTrue($this->connection->isConnected());
}


public function testHasDatabase()
{
$this->assertFalse($this->connection->hasDatabase('__unknown__database__'));
Expand Down Expand Up @@ -83,15 +81,13 @@ public function testGetMongoObject()
$this->assertInstanceOf('MongoClient', $mongo);
}


public function testDropUnknownDatabase()
{
$result = $this->connection->dropDatabase('_unknown_');

$this->assertTrue($result);
}


public function testDropKnownDatabase()
{
$mongo = $this->connection->getConnection();
Expand All @@ -102,28 +98,24 @@ public function testDropKnownDatabase()
$this->assertTrue($result);
}


public function testGetDatabase()
{
$database = $this->connection->database('my_db');
$this->assertInstanceOf('League\Monga\Database', $database);
}


public function testGetMongoDatabase()
{
$database = $this->connection->database('my_db', false);
$this->assertInstanceOf('MongoDB', $database);
}


public function testGetConnection()
{
$mongo = $this->connection->getConnection();
$this->assertInstanceOf('MongoClient', $mongo);
}


public function testReplaceConnection()
{
$original = $this->connection->getConnection();
Expand Down
8 changes: 4 additions & 4 deletions tests/CursorTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function testCursor()

$ids = $collection->insert($values);

foreach($values as $index => &$row) {
foreach ($values as $index => &$row) {
$row['_id'] = $ids[$index];
}

Expand All @@ -33,7 +33,7 @@ public function testCursor()
$this->assertEquals(3, $cursor->count());
$this->assertInstanceOf('League\Monga\Collection', $oldCollection);

foreach($cursor as $row) {
foreach ($cursor as $row) {
$this->assertInternalType('array', $row);
}

Expand All @@ -52,8 +52,8 @@ public function testCursor()
}

/**
* @expectedException BadMethodCallException
*/
* @expectedException BadMethodCallException
*/
public function testBadMethodCall()
{
$mock = $this->getMockBuilder('MongoCursor')
Expand Down
4 changes: 2 additions & 2 deletions tests/DatabaseTests.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use League\Monga;
use League\Monga\Connection;
use League\Monga\Database;
use League\Monga;

class DatabaseTests extends PHPUnit_Framework_TestCase
{
Expand All @@ -12,7 +12,7 @@ class DatabaseTests extends PHPUnit_Framework_TestCase

public function setUp()
{
if ( ! $this->connection) {
if (! $this->connection) {
$this->connection = Monga::connection();
}

Expand Down
1 change: 0 additions & 1 deletion tests/FilesystemTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public function testExtractFailing()
->with('filename.json')
->will($this->returnValue(new FileMock(false)));


$fs = new League\Monga\Filesystem($mock);

$this->assertFalse($fs->extract('filename.json'));
Expand Down
4 changes: 2 additions & 2 deletions tests/MongaTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public function testMongaRegex()
}

/**
* @expectedException MongoException
*/
* @expectedException MongoException
*/
public function testInvalidRegex()
{
$regex = Monga::regex('#(.*)#imu');
Expand Down
1 change: 0 additions & 1 deletion tests/QueryAggregateTests.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use League\Monga\Query\Aggregation as Agr;
use Mockery as m;

class QueryAggregateTests extends PHPUnit_Framework_TestCase
{
Expand Down
10 changes: 6 additions & 4 deletions tests/QueryBuilderTests.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

class BuilderMock extends League\Monga\Query\Builder {}
class BuilderMock extends League\Monga\Query\Builder
{
}

class QueryBuilderTests extends PHPUnit_Framework_TestCase
{
Expand All @@ -16,6 +18,7 @@ public function getProperty($property)
$reflection = new ReflectionObject($this->builder);
$property = $property = $reflection->getProperty($property);
$property->setAccessible(true);

return $property->getValue($this->builder);
}

Expand Down Expand Up @@ -68,16 +71,15 @@ public function testGetOptions()
$this->assertEquals(array(
'w' => 0,
'fsync' => false,
'timeout' => MongoCursor::$timeout
'timeout' => MongoCursor::$timeout,
), $result);

$result = $this->builder->timeout(100)->getOptions();


$this->assertEquals(array(
'w' => 0,
'fsync' => false,
'timeout' => 100
'timeout' => 100,
), $result);
}
}
Loading

0 comments on commit 4d34b29

Please sign in to comment.