Skip to content

Commit bf1e2bb

Browse files
committed
more improvements
1 parent 8017d9c commit bf1e2bb

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/Symfony/Bridge/Doctrine/Tests/Decorator/DoctrineTransactionDecoratorTest.php

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,34 +43,26 @@ protected function setUp(): void
4343

4444
public function testDecoratorWrapsInTransactionAndFlushes()
4545
{
46-
$this->connection->expects($this->once())
47-
->method('beginTransaction')
48-
;
49-
$this->connection->expects($this->once())
50-
->method('commit')
51-
;
52-
$this->entityManager->expects($this->once())
53-
->method('flush')
54-
;
55-
5646
$handler = new TestHandler();
47+
48+
$this->connection->expects($this->once())->method('beginTransaction');
49+
$this->connection->expects($this->once())->method('commit');
50+
$this->entityManager->expects($this->once())->method('flush');
51+
5752
$result = $this->decorator->call($handler->handle(...));
5853
$this->assertSame('success', $result);
5954
}
6055

6156
public function testTransactionIsRolledBackOnException()
6257
{
63-
$this->connection->expects($this->once())
64-
->method('beginTransaction')
65-
;
66-
$this->connection->expects($this->once())
67-
->method('rollBack')
68-
;
58+
$this->connection->expects($this->once())->method('beginTransaction');
59+
$this->connection->expects($this->once())->method('rollBack');
60+
61+
$handler = new TestHandler();
6962

7063
$this->expectException(\RuntimeException::class);
7164
$this->expectExceptionMessage('A runtime error.');
7265

73-
$handler = new TestHandler();
7466
$this->decorator->call($handler->handleWithError(...));
7567
}
7668

@@ -79,11 +71,12 @@ public function testInvalidEntityManagerThrowsException()
7971
$this->managerRegistry
8072
->method('getManager')
8173
->with('unknown_manager')
82-
->will($this->throwException(new \InvalidArgumentException()));
74+
->willThrowException(new \InvalidArgumentException());
75+
76+
$handler = new TestHandler();
8377

8478
$this->expectException(\InvalidArgumentException::class);
8579

86-
$handler = new TestHandler();
8780
$this->decorator->call($handler->handleWithUnknownManager(...));
8881
}
8982
}

0 commit comments

Comments
 (0)