-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
assertSame instead of assertEquals (#199)
- Loading branch information
1 parent
b15254b
commit d82b6e5
Showing
8 changed files
with
27 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,9 +46,9 @@ Let's redefine static methods and verify their calls at runtime. | |
|
||
function testTableName() | ||
{ | ||
$this->assertEquals('users', UserModel::tableName()); | ||
$this->assertSame('users', UserModel::tableName()); | ||
$userModel = test::double('UserModel', ['tableName' => 'my_users']); | ||
$this->assertEquals('my_users', UserModel::tableName()); | ||
$this->assertSame('my_users', UserModel::tableName()); | ||
$userModel->verifyInvoked('tableName'); | ||
} | ||
``` | ||
|
@@ -83,7 +83,7 @@ function testUserCreate() | |
$user = test::double('User', ['save' => null]); | ||
$service = new UserService; | ||
$service->createUserByName('davert'); | ||
$this->assertEquals('davert', $user->getName()); | ||
$this->assertSame('davert', $user->getName()); | ||
$user->verifyInvoked('save'); | ||
} | ||
``` | ||
|
@@ -99,10 +99,10 @@ function testUserCreate() | |
$AR = test::double('ActiveRecord', ['save' => null])); | ||
test::double('User', ['findByNameAndEmail' => new User(['name' => 'jon'])])); | ||
$user = User::findByNameAndEmail('jon','[email protected]'); // magic method | ||
$this->assertEquals('jon', $user->getName()); | ||
$this->assertSame('jon', $user->getName()); | ||
$user->save(['name' => 'miles']); // ActiveRecord->save did not hit database | ||
$AR->verifyInvoked('save'); | ||
$this->assertEquals('miles', $user->getName()); | ||
$this->assertSame('miles', $user->getName()); | ||
} | ||
``` | ||
|
||
|
@@ -113,7 +113,7 @@ function testUserCreate() | |
|
||
namespace demo; | ||
test::func('demo', 'time', 'now'); | ||
$this->assertEquals('now', time()); | ||
$this->assertSame('now', time()); | ||
``` | ||
|
||
#### Beautifully simple | ||
|
@@ -126,7 +126,7 @@ Only 4 methods are necessary for method call verification and one method to defi | |
function testSimpleStubAndMock() | ||
{ | ||
$user = test::double(new User, ['getName' => 'davert']); | ||
$this->assertEquals('davert', $user->getName()); | ||
$this->assertSame('davert', $user->getName()); | ||
$user->verifyInvoked('getName'); | ||
$user->verifyInvokedOnce('getName'); | ||
$user->verifyNeverInvoked('setName'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters