Skip to content

Commit 69242dc

Browse files
Code review changes
1 parent 5effeae commit 69242dc

File tree

4 files changed

+3
-54
lines changed

4 files changed

+3
-54
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
},
1515
"require": {
1616
"php": "^7.1",
17+
"ext-mongodb": "*",
1718
"mongodb/mongodb": "^1.4",
1819
"symfony/console": "^2.7|^3.3|^4",
1920
"symfony/yaml": "^2.7|^3.3|^4"

src/AntiMattr/MongoDB/Migrations/Collection/Statistics.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,6 @@ protected function getCollectionStats()
131131
throw new Exception($message);
132132
}
133133

134-
/* new MongoDB\Driver\Cursor does not have an errmsg, it throws exceptions itself */
135-
/* Disabled for now @todo what to do with this? */
136-
/*
137-
if (isset($data['errmsg'])) {
138-
throw new Exception($data['errmsg']);
139-
}
140-
*/
141-
142134
return $data;
143135
}
144136
}

src/AntiMattr/MongoDB/Migrations/Version.php

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ class Version
4040
*/
4141
private $configuration;
4242

43-
/**
44-
* @var \MongoDB\Connection
45-
*/
46-
private $connection;
47-
4843
/**
4944
* @var \MongoDB\Database
5045
*/
@@ -87,7 +82,6 @@ public function __construct(Configuration $configuration, $version, $class)
8782
$this->configuration = $configuration;
8883
$this->outputWriter = $configuration->getOutputWriter();
8984
$this->class = $class;
90-
$this->connection = $configuration->getConnection();
9185
$this->db = $configuration->getDatabase();
9286
$this->migration = $this->createMigration();
9387
$this->version = $version;
@@ -280,16 +274,7 @@ public function executeScript(Database $db, $file)
280274
throw $e;
281275
}
282276

283-
$result = $db->command(['$eval' => $js, 'nolock' => true]);
284-
285-
/* Command throws it's own exceptions if something is wrong, this errmsg no longer exists on MongoDB\DriverCursor
286-
@todo what to do with this, disabled for now
287-
if (isset($result['errmsg'])) {
288-
throw new \Exception($result['errmsg'], isset($result['errno']) ? $result['errno'] : null);
289-
}
290-
*/
291-
292-
return $result;
277+
return $db->command(['$eval' => $js, 'nolock' => true]);
293278
}
294279

295280
/**
@@ -379,7 +364,7 @@ private function summarizeStatistics()
379364

380365
public function __toString()
381366
{
382-
return $this->version;
367+
return (string) $this->version;
383368
}
384369

385370
/**

tests/AntiMattr/Tests/MongoDB/Migrations/Collection/StatisticsTest.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,6 @@ public function testGetCollectionStatsThrowsExceptionWhenDataNotFound()
4040
$this->statistics->doGetCollectionStats();
4141
}
4242

43-
/**
44-
* @expectedException \Exception
45-
*/
46-
public function testGetCollectionStatsThrowsExceptionWhenErrmsgFound()
47-
{
48-
$database = $this->createMock('MongoDB\Database');
49-
50-
$this->statistics = new StatisticsStub();
51-
$this->statistics->setCollection($this->collection);
52-
$this->statistics->setDatabase($database);
53-
54-
$this->collection->expects($this->once())
55-
->method('getCollectionName')
56-
->will($this->returnValue('example'));
57-
58-
$data = [
59-
'errmsg' => 'foo',
60-
];
61-
62-
$database->expects($this->once())
63-
->method('command')
64-
->will($this->returnValue($data));
65-
66-
// Can't test it this way as it will return a MongoDB\Driver\Cursor which does not have a errmsg array
67-
// @todo what do to do here, remove this test?
68-
//$this->statistics->doGetCollectionStats();
69-
$this->markTestIncomplete('This method needs to act on a MongoDB\Driver\Cursor object which has no error method');
70-
}
71-
7243
public function testGetCollectionStats()
7344
{
7445
$database = $this->createMock('MongoDB\Database');

0 commit comments

Comments
 (0)