Skip to content

Commit 324fd57

Browse files
transistiveMulkave
andauthored
V1.8 (#353)
* added missing migration methods * fixed errors with undefined method * set 2.3.3 as minimum req for driver * use fire instead of dispatch * fix tests Co-authored-by: Abed Halawi <[email protected]>
1 parent c7aa2aa commit 324fd57

File tree

7 files changed

+20
-33
lines changed

7 files changed

+20
-33
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
"illuminate/support": "^8.0",
2929
"illuminate/pagination": "^8.0",
3030
"nesbot/carbon": "^2.0",
31-
"laudis/neo4j-php-client": "^2.2"
31+
"laudis/neo4j-php-client": "^2.3.3"
3232
},
3333
"require-dev": {
3434
"mockery/mockery": "~1.3.0",

src/Connection.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ public function getDriverName()
524524
* @param string $query
525525
* @param array $bindings
526526
*
527-
* @return CypherList
527+
* @return SummarizedResult
528528
*/
529529
public function select($query, $bindings = array())
530530
{
@@ -539,11 +539,7 @@ public function select($query, $bindings = array())
539539
$query = $me->getCypherQuery($query, $bindings);
540540

541541
/** @var SummarizedResult $results */
542-
$summary = $this->getClient()->run($query['statement'], $query['parameters']);
543-
/** @var CypherList $results */
544-
$results = $summary->getResult();
545-
546-
return $results;
542+
return $this->getClient()->run($query['statement'], $query['parameters']);
547543
});
548544
}
549545

@@ -631,8 +627,7 @@ public function statement($query, $bindings = array(), $rawResults = false)
631627
$query = $me->getCypherQuery($query, $bindings);
632628

633629
/** @var SummarizedResult $run */
634-
$run = $this->getClient()->run($query['statement'], $query['parameters']);
635-
$results = $run->getResult();
630+
$results = $this->getClient()->run($query['statement'], $query['parameters']);
636631

637632
return ($rawResults === true) ? $results : true;
638633
});
@@ -1083,7 +1078,7 @@ protected function reconnectIfMissingConnection()
10831078
public function logQuery($query, $bindings, $time = null)
10841079
{
10851080
if (isset($this->events)) {
1086-
$this->events->fire('illuminate.query', [$query, $bindings, $time, $this->getName()]);
1081+
$this->events->dispatch('illuminate.query', [$query, $bindings, $time, $this->getName()]);
10871082
}
10881083

10891084
if ($this->loggingQueries) {
@@ -1111,7 +1106,7 @@ public function listen(Closure $callback)
11111106
protected function fireConnectionEvent($event)
11121107
{
11131108
if (isset($this->events)) {
1114-
$this->events->fire('connection.'.$this->getName().'.'.$event, $this);
1109+
$this->events->dispatch('connection.'.$this->getName().'.'.$event, $this);
11151110
}
11161111
}
11171112

src/Eloquent/Model.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
namespace Vinelab\NeoEloquent\Eloquent;
44

5+
use BadMethodCallException;
56
use DateTime;
67
use Exception;
78
use ArrayAccess;
89
use Carbon\Carbon;
910
use LogicException;
1011
use JsonSerializable;
11-
use BadMethodCallException;
1212
use Vinelab\NeoEloquent\Eloquent\Builder as EloquentBuilder;
1313
use Vinelab\NeoEloquent\Eloquent\Relations\BelongsTo;
1414
use Vinelab\NeoEloquent\Eloquent\Relations\BelongsToMany;

src/Query/Builder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ public function update(array $values)
368368

369369
$bindings = $this->getBindingsMergedWithValues($values, true);
370370

371-
$updated = $this->connection->update($cypher, $bindings)->getResult();
371+
$updated = $this->connection->update($cypher, $bindings);
372372

373373
return ($updated) ? count(current($this->getRecordsByPlaceholders($updated))) : 0;
374374
}

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ protected function getNodeById($id)
9797
/** @var SummarizedResult $result */
9898
$result = $client->run("MATCH (n) WHERE id(n)=$id RETURN n");
9999

100-
return $result->getResult()->first()->first()->getValue();
100+
return $result->first()->first()->getValue();
101101
}
102102

103103
/**

tests/Vinelab/NeoEloquent/ConnectionTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Laudis\Neo4j\Contracts\ClientInterface;
66
use Laudis\Neo4j\Databags\SummarizedResult;
77
use Laudis\Neo4j\Types\CypherList;
8+
use Laudis\Neo4j\Types\CypherMap;
89
use Mockery as M;
910

1011
class ConnectionTest extends TestCase
@@ -116,7 +117,7 @@ public function testLogQueryFiresEventsIfSet()
116117
$connection = $this->getMockConnection();
117118
$connection->logQuery('foo', array(), time());
118119
$connection->setEventDispatcher($events = M::mock('Illuminate\Contracts\Events\Dispatcher'));
119-
$events->shouldReceive('fire')->once()->with('illuminate.query', array('foo', array(), null, null));
120+
$events->shouldReceive('dispatch')->once()->with('illuminate.query', array('foo', array(), null, null));
120121
$connection->logQuery('foo', array(), null);
121122

122123
self::assertTrue(true);
@@ -331,16 +332,17 @@ public function testAffectingStatement()
331332

332333
$this->assertInstanceOf(SummarizedResult::class, $results);
333334

335+
/** @var CypherMap $result */
334336
foreach ($results as $result) {
335-
$count = $result[0];
337+
$count = $result->first()->getValue();
336338
$this->assertEquals(1, $count);
337339
}
338340

339341
// Try to find the updated one and make sure it was updated successfully
340342
$query = 'MATCH (n:User) WHERE n.username = $username RETURN n';
341343
$cypher = $c->getCypherQuery($query, array('username' => $this->user['username']));
342344

343-
$results = $this->client->run($cypher['statement'], $cypher['parameters'])->getResult();
345+
$results = $this->client->run($cypher['statement'], $cypher['parameters']);
344346

345347
$this->assertInstanceOf(CypherList::class, $results);
346348

@@ -370,8 +372,9 @@ public function testAffectingStatementOnNonExistingRecord()
370372

371373
$this->assertInstanceOf(SummarizedResult::class, $results);
372374

375+
/** @var CypherMap $result */
373376
foreach ($results as $result) {
374-
$count = $result[0];
377+
$count = $result->first()->getValue();
375378
$this->assertEquals(0, $count);
376379
}
377380
}
@@ -432,7 +435,7 @@ public function testBeganTransactionFiresEventsIfSet()
432435
$connection = $this->getMockConnection(array('getName'));
433436
$connection->expects($this->once())->method('getName')->will($this->returnValue('name'));
434437
$connection->setEventDispatcher($events = M::mock('Illuminate\Contracts\Events\Dispatcher'));
435-
$events->shouldReceive('fire')->once()->with('connection.name.beganTransaction', $connection);
438+
$events->shouldReceive('dispatch')->once()->with('connection.name.beganTransaction', $connection);
436439
$connection->beginTransaction();
437440
}
438441

@@ -441,7 +444,7 @@ public function testCommitedFiresEventsIfSet()
441444
$connection = $this->getMockConnection(array('getName'));
442445
$connection->expects($this->once())->method('getName')->will($this->returnValue('name'));
443446
$connection->setEventDispatcher($events = M::mock('Illuminate\Contracts\Events\Dispatcher'));
444-
$events->shouldReceive('fire')->once()->with('connection.name.committed', $connection);
447+
$events->shouldReceive('dispatch')->once()->with('connection.name.committed', $connection);
445448
$connection->commit();
446449
}
447450

@@ -450,7 +453,7 @@ public function testRollBackedFiresEventsIfSet()
450453
$connection = $this->getMockConnection(array('getName'));
451454
$connection->expects($this->once())->method('getName')->will($this->returnValue('name'));
452455
$connection->setEventDispatcher($events = M::mock('Illuminate\Contracts\Events\Dispatcher'));
453-
$events->shouldReceive('fire')->once()->with('connection.name.rollingBack', $connection);
456+
$events->shouldReceive('dispatch')->once()->with('connection.name.rollingBack', $connection);
454457
$connection->rollback();
455458
}
456459

tests/Vinelab/NeoEloquent/Query/BuilderTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,7 @@ public function testInsertingAndGettingId()
7979
$this->neoClient->shouldReceive('run')
8080
->once()
8181
->with($query['statement'], $query['parameters'])
82-
->andReturn(new SummarizedResult($result, new ResultSummary(
83-
new SummaryCounters(),
84-
new DatabaseInfo(''),
85-
new CypherList(),
86-
null,
87-
null,
88-
new Statement($query['statement'], $query['parameters']),
89-
QueryTypeEnum::READ_WRITE(),
90-
0,
91-
0,
92-
new ServerInfo(Uri::create(), ConnectionProtocol::BOLT_V40(), 'agent')
93-
)));
82+
->andReturn(new CypherList($result));
9483

9584
$this->assertEquals($id, $this->builder->insertGetId($values));
9685
}

0 commit comments

Comments
 (0)