forked from alcaeus/mongo-php-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request alcaeus#272 from alcaeus/phpunit-bridge
Use PHPUnit bridge to test on multiple PHP versions
- Loading branch information
Showing
23 changed files
with
83 additions
and
61 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
composer.lock | ||
.phpcs-cache | ||
.phpunit.result.cache | ||
vendor/ | ||
tests/scripts/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
use Alcaeus\MongoDbAdapter\Tests\TestCase; | ||
use Alcaeus\MongoDbAdapter\TypeInterface; | ||
use ReflectionProperty; | ||
|
||
/** | ||
* @author alcaeus <[email protected]> | ||
|
@@ -13,8 +14,9 @@ class MongoCodeTest extends TestCase | |
public function testCreate() | ||
{ | ||
$code = new \MongoCode('code', ['scope' => 'bleh']); | ||
$this->assertAttributeSame('code', 'code', $code); | ||
$this->assertAttributeSame(['scope' => 'bleh'], 'scope', $code); | ||
|
||
$this->assertSame('code', $this->getAttributeValue($code, 'code')); | ||
$this->assertSame(['scope' => 'bleh'], $this->getAttributeValue($code, 'scope')); | ||
|
||
$this->assertSame('code', (string) $code); | ||
|
||
|
@@ -39,7 +41,15 @@ public function testCreateWithBsonObject() | |
$bsonCode = new \MongoDB\BSON\Javascript('code', ['scope' => 'bleh']); | ||
$code = new \MongoCode($bsonCode); | ||
|
||
$this->assertAttributeSame('code', 'code', $code); | ||
$this->assertAttributeSame(['scope' => 'bleh'], 'scope', $code); | ||
$this->assertSame('code', $this->getAttributeValue($code, 'code')); | ||
$this->assertSame(['scope' => 'bleh'], $this->getAttributeValue($code, 'scope')); | ||
} | ||
|
||
private function getAttributeValue(\MongoCode $code, $attribute) | ||
{ | ||
$property = new ReflectionProperty($code, $attribute); | ||
$property->setAccessible(true); | ||
|
||
return $property->getValue($code); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
use Alcaeus\MongoDbAdapter\Tests\TestCase; | ||
use MongoDB\BSON\ObjectID; | ||
use ReflectionProperty; | ||
|
||
/** | ||
* @author alcaeus <[email protected]> | ||
|
@@ -40,12 +41,11 @@ public function testCreateWithString() | |
$this->assertSame(34335, $id->getPID()); | ||
} | ||
|
||
/** | ||
* @expectedException \MongoException | ||
* @expectedExceptionMessage Invalid object ID | ||
*/ | ||
public function testCreateWithInvalidStringThrowsMongoException() | ||
{ | ||
$this->expectException('\MongoException'); | ||
$this->expectExceptionMessage('Invalid object ID'); | ||
|
||
new \MongoId('invalid'); | ||
} | ||
|
||
|
@@ -59,7 +59,7 @@ public function testCreateWithObjectId() | |
$id = new \MongoId($objectId); | ||
$this->assertSame($original, (string) $id); | ||
|
||
$this->assertAttributeNotSame($objectId, 'objectID', $id); | ||
$this->assertNotSame($objectId, $this->getAttributeValue($id, 'objectID')); | ||
} | ||
|
||
/** | ||
|
@@ -83,4 +83,12 @@ public static function dataIsValid() | |
'object' => [false, new \stdClass()], | ||
]; | ||
} | ||
|
||
private function getAttributeValue(\MongoId $id, $attribute) | ||
{ | ||
$property = new ReflectionProperty($id, $attribute); | ||
$property->setAccessible(true); | ||
|
||
return $property->getValue($id); | ||
} | ||
} |
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
Oops, something went wrong.