Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55bad15

Browse files
committed
use PHPUnit 13 on PHP 8.4+
1 parent d2d638e commit 55bad15

4 files changed

Lines changed: 18 additions & 16 deletions

File tree

Tests/Transport/ConnectionTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public function testGetWithSkipLockedWithForUpdateMethod()
113113
$this->markTestSkipped('This test is for when forUpdate method exists.');
114114
}
115115

116-
$queryBuilder = $this->getQueryBuilderStub();
116+
$queryBuilder = $this->getQueryBuilderMock();
117117
$driverConnection = $this->getDBALConnection(true);
118118
$stmt = $this->getResultMock(false);
119119

@@ -124,6 +124,7 @@ public function testGetWithSkipLockedWithForUpdateMethod()
124124
->method('getParameterTypes')
125125
->willReturn([]);
126126
$queryBuilder
127+
->expects($this->once())
127128
->method('forUpdate')
128129
->with(ConflictResolutionMode::SKIP_LOCKED)
129130
->willReturn($queryBuilder);
@@ -575,7 +576,7 @@ public function testItThrowsAnExceptionIfAnExtraOptionsInDefinedInDSN()
575576

576577
public function testFind()
577578
{
578-
$queryBuilder = $this->getQueryBuilderStub();
579+
$queryBuilder = $this->getQueryBuilderMock();
579580
$driverConnection = $this->getDBALConnection();
580581
$id = 1;
581582
$stmt = $this->getResultMock([
@@ -588,6 +589,7 @@ public function testFind()
588589
->method('createQueryBuilder')
589590
->willReturn($queryBuilder);
590591
$queryBuilder
592+
->expects($this->once())
591593
->method('where')
592594
->with('m.id = ? and m.queue_name = ?')
593595
->willReturn($queryBuilder);

Tests/Transport/DoctrineReceiverTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ public function testAll()
116116

117117
$doctrineEnvelope1 = $this->createDoctrineEnvelope();
118118
$doctrineEnvelope2 = $this->createDoctrineEnvelope();
119-
$connection = $this->createStub(Connection::class);
120-
$connection->method('findAll')->with(50)->willReturn([$doctrineEnvelope1, $doctrineEnvelope2]);
119+
$connection = $this->createMock(Connection::class);
120+
$connection->expects($this->once())->method('findAll')->with(50)->willReturn([$doctrineEnvelope1, $doctrineEnvelope2]);
121121

122122
$receiver = new DoctrineReceiver($connection, $serializer);
123123
$actualEnvelopes = iterator_to_array($receiver->all(50));
@@ -131,8 +131,8 @@ public function testAllReplacesExistingTransportMessageIdStamps()
131131

132132
$doctrineEnvelope1 = $this->createRetriedDoctrineEnvelope();
133133
$doctrineEnvelope2 = $this->createRetriedDoctrineEnvelope();
134-
$connection = $this->createStub(Connection::class);
135-
$connection->method('findAll')->willReturn([$doctrineEnvelope1, $doctrineEnvelope2]);
134+
$connection = $this->createMock(Connection::class);
135+
$connection->expects($this->once())->method('findAll')->willReturn([$doctrineEnvelope1, $doctrineEnvelope2]);
136136

137137
$receiver = new DoctrineReceiver($connection, $serializer);
138138
$actualEnvelopes = $receiver->all();
@@ -148,8 +148,8 @@ public function testFind()
148148
$serializer = $this->createSerializer();
149149

150150
$doctrineEnvelope = $this->createDoctrineEnvelope();
151-
$connection = $this->createStub(Connection::class);
152-
$connection->method('find')->with(10)->willReturn($doctrineEnvelope);
151+
$connection = $this->createMock(Connection::class);
152+
$connection->expects($this->once())->method('find')->with(10)->willReturn($doctrineEnvelope);
153153

154154
$receiver = new DoctrineReceiver($connection, $serializer);
155155
$actualEnvelope = $receiver->find(10);
@@ -161,8 +161,8 @@ public function testFindReplacesExistingTransportMessageIdStamps()
161161
$serializer = $this->createSerializer();
162162

163163
$doctrineEnvelope = $this->createRetriedDoctrineEnvelope();
164-
$connection = $this->createStub(Connection::class);
165-
$connection->method('find')->with(3)->willReturn($doctrineEnvelope);
164+
$connection = $this->createMock(Connection::class);
165+
$connection->expects($this->once())->method('find')->with(3)->willReturn($doctrineEnvelope);
166166

167167
$receiver = new DoctrineReceiver($connection, $serializer);
168168
$actualEnvelope = $receiver->find(3);

Tests/Transport/DoctrineSenderTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public function testSend()
3030
$connection = $this->createMock(Connection::class);
3131
$connection->expects($this->once())->method('send')->with($encoded['body'], $encoded['headers'])->willReturn('15');
3232

33-
$serializer = $this->createStub(SerializerInterface::class);
34-
$serializer->method('encode')->with($envelope)->willReturn($encoded);
33+
$serializer = $this->createMock(SerializerInterface::class);
34+
$serializer->expects($this->once())->method('encode')->with($envelope)->willReturn($encoded);
3535

3636
$sender = new DoctrineSender($connection, $serializer);
3737
$actualEnvelope = $sender->send($envelope);
@@ -50,8 +50,8 @@ public function testSendWithDelay()
5050
$connection = $this->createMock(Connection::class);
5151
$connection->expects($this->once())->method('send')->with($encoded['body'], $encoded['headers'], 500);
5252

53-
$serializer = $this->createStub(SerializerInterface::class);
54-
$serializer->method('encode')->with($envelope)->willReturn($encoded);
53+
$serializer = $this->createMock(SerializerInterface::class);
54+
$serializer->expects($this->once())->method('encode')->with($envelope)->willReturn($encoded);
5555

5656
$sender = new DoctrineSender($connection, $serializer);
5757
$sender->send($envelope);

Tests/Transport/DoctrineTransportTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function testItIsATransport()
3434
public function testReceivesMessages()
3535
{
3636
$transport = $this->getTransport(
37-
$serializer = $this->createStub(SerializerInterface::class),
37+
$serializer = $this->createMock(SerializerInterface::class),
3838
$connection = $this->createStub(Connection::class)
3939
);
4040

@@ -46,7 +46,7 @@ public function testReceivesMessages()
4646
'headers' => ['my' => 'header'],
4747
];
4848

49-
$serializer->method('decode')->with(['body' => 'body', 'headers' => ['my' => 'header']])->willReturn(new Envelope($decodedMessage));
49+
$serializer->expects($this->once())->method('decode')->with(['body' => 'body', 'headers' => ['my' => 'header']])->willReturn(new Envelope($decodedMessage));
5050
$connection->method('get')->willReturn($doctrineEnvelope);
5151

5252
$envelopes = $transport->get();

0 commit comments

Comments
 (0)