Skip to content

Commit 5164e0e

Browse files
authored
Simplify mocking assertions. (#40786)
1 parent 0a973b1 commit 5164e0e

File tree

4 files changed

+11
-13
lines changed

4 files changed

+11
-13
lines changed

tests/Database/DatabaseConnectorTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ public function testPostgresSearchPathCommaSeparatedValueSupported()
129129
$config = ['host' => 'foo', 'database' => 'bar', 'search_path' => 'public, "user"', 'charset' => 'utf8'];
130130
$connector = $this->getMockBuilder('Illuminate\Database\Connectors\PostgresConnector')->setMethods(['createConnection', 'getOptions'])->getMock();
131131
$connection = m::mock('stdClass');
132-
$connector->expects($this->once())->method('getOptions')->with($this->equalTo($config))->will($this->returnValue(['options']));
133-
$connector->expects($this->once())->method('createConnection')->with($this->equalTo($dsn), $this->equalTo($config), $this->equalTo(['options']))->will($this->returnValue($connection));
132+
$connector->expects($this->once())->method('getOptions')->with($this->equalTo($config))->willReturn(['options']);
133+
$connector->expects($this->once())->method('createConnection')->with($this->equalTo($dsn), $this->equalTo($config), $this->equalTo(['options']))->willReturn($connection);
134134
$connection->shouldReceive('prepare')->once()->with('set names \'utf8\'')->andReturn($connection);
135135
$connection->shouldReceive('prepare')->once()->with('set search_path to "public", "user"')->andReturn($connection);
136136
$connection->shouldReceive('execute')->twice();
@@ -145,8 +145,8 @@ public function testPostgresSearchPathVariablesSupported()
145145
$config = ['host' => 'foo', 'database' => 'bar', 'search_path' => '"$user", public, user', 'charset' => 'utf8'];
146146
$connector = $this->getMockBuilder('Illuminate\Database\Connectors\PostgresConnector')->setMethods(['createConnection', 'getOptions'])->getMock();
147147
$connection = m::mock('stdClass');
148-
$connector->expects($this->once())->method('getOptions')->with($this->equalTo($config))->will($this->returnValue(['options']));
149-
$connector->expects($this->once())->method('createConnection')->with($this->equalTo($dsn), $this->equalTo($config), $this->equalTo(['options']))->will($this->returnValue($connection));
148+
$connector->expects($this->once())->method('getOptions')->with($this->equalTo($config))->willReturn(['options']);
149+
$connector->expects($this->once())->method('createConnection')->with($this->equalTo($dsn), $this->equalTo($config), $this->equalTo(['options']))->willReturn($connection);
150150
$connection->shouldReceive('prepare')->once()->with('set names \'utf8\'')->andReturn($connection);
151151
$connection->shouldReceive('prepare')->once()->with('set search_path to "$user", "public", "user"')->andReturn($connection);
152152
$connection->shouldReceive('execute')->twice();

tests/Foundation/Testing/DatabaseMigrationsTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName)
4646
public function testRefreshTestDatabaseDefault()
4747
{
4848
$this->traitObject
49-
->expects($this->exactly(1))
49+
->expects($this->once())
5050
->method('artisan')
5151
->with('migrate:fresh', [
5252
'--drop-views' => false,
@@ -64,7 +64,7 @@ public function testRefreshTestDatabaseWithDropViewsOption()
6464
$this->traitObject->dropViews = true;
6565

6666
$this->traitObject
67-
->expects($this->exactly(1))
67+
->expects($this->once())
6868
->method('artisan')
6969
->with('migrate:fresh', [
7070
'--drop-views' => true,
@@ -82,7 +82,7 @@ public function testRefreshTestDatabaseWithDropTypesOption()
8282
$this->traitObject->dropTypes = true;
8383

8484
$this->traitObject
85-
->expects($this->exactly(1))
85+
->expects($this->once())
8686
->method('artisan')
8787
->with('migrate:fresh', [
8888
'--drop-views' => false,

tests/Foundation/Testing/RefreshDatabaseTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private function __reflectAndSetupAccessibleForProtectedTraitMethod($methodName)
4646
public function testRefreshTestDatabaseDefault()
4747
{
4848
$this->traitObject
49-
->expects($this->exactly(1))
49+
->expects($this->once())
5050
->method('artisan')
5151
->with('migrate:fresh', [
5252
'--drop-views' => false,
@@ -64,7 +64,7 @@ public function testRefreshTestDatabaseWithDropViewsOption()
6464
$this->traitObject->dropViews = true;
6565

6666
$this->traitObject
67-
->expects($this->exactly(1))
67+
->expects($this->once())
6868
->method('artisan')
6969
->with('migrate:fresh', [
7070
'--drop-views' => true,
@@ -82,7 +82,7 @@ public function testRefreshTestDatabaseWithDropTypesOption()
8282
$this->traitObject->dropTypes = true;
8383

8484
$this->traitObject
85-
->expects($this->exactly(1))
85+
->expects($this->once())
8686
->method('artisan')
8787
->with('migrate:fresh', [
8888
'--drop-views' => false,

tests/Support/SupportNamespacedItemResolverTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public function testParsedItemsAreCached()
3030
public function testParsedItemsMayBeFlushed()
3131
{
3232
$r = $this->getMockBuilder(NamespacedItemResolver::class)->onlyMethods(['parseBasicSegments', 'parseNamespacedSegments'])->getMock();
33-
$r->expects($this->once())->method('parseBasicSegments')->will(
34-
$this->returnValue(['bar'])
35-
);
33+
$r->expects($this->once())->method('parseBasicSegments')->willReturn(['bar']);
3634

3735
$r->setParsedKey('foo.bar', ['foo']);
3836
$r->flushParsedKeys();

0 commit comments

Comments
 (0)