Skip to content

Commit

Permalink
move from MockBuilder to Prophecty
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Dec 10, 2024
1 parent 05c4aa9 commit c0ae5df
Show file tree
Hide file tree
Showing 60 changed files with 403 additions and 521 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"autoload-dev": {
"psr-4": {
"Google\\ApiCore\\Dev\\": "dev/src",
"Google\\ApiCore\\": "tests",
"Google\\ApiCore\\Tests\\": "tests",
"GPBMetadata\\Google\\": "metadata/Google"
}
},
Expand Down
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" colors="true">
<php>
<env name="GOOGLE_APPLICATION_CREDENTIALS" value="tests/Tests/Unit/testdata/json-key-file.json"/>
<env name="GOOGLE_APPLICATION_CREDENTIALS" value="tests/Unit/testdata/json-key-file.json"/>
</php>
<coverage>
<include>
Expand All @@ -10,7 +10,7 @@
</coverage>
<testsuites>
<testsuite name="unit">
<directory>tests/Tests/Unit</directory>
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
</phpunit>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@
use InvalidArgumentException;
use LengthException;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

class FixedSizeCollectionTest extends TestCase
{
use TestTrait;
use ProphecyTrait;

private function createPage($responseSequence)
{
Expand Down Expand Up @@ -174,29 +176,26 @@ public function testApiReturningMoreElementsThanPageSize()
public function testEmptyCollectionThrowsException()
{
$collectionSize = 0;
$page = $this->getMockBuilder(Page::class)
->disableOriginalConstructor()
->getMock();
$page = $this->prophesize(Page::class);

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('collectionSize must be > 0.');

new FixedSizeCollection($page, $collectionSize);
new FixedSizeCollection($page->reveal(), $collectionSize);
}

public function testInvalidPageCount()
{
$collectionSize = 1;
$page = $this->getMockBuilder(Page::class)
->disableOriginalConstructor()
->getMock();
$page->expects($this->exactly(2))
->method('getPageElementCount')
->will($this->returnValue(2));
$page = $this->prophesize(Page::class);

$page->getPageElementCount()
->shouldBeCalledTimes(2)
->willReturn(2);

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('collectionSize must be greater than or equal to the number of elements in initialPage');

new FixedSizeCollection($page, $collectionSize);
new FixedSizeCollection($page->reveal(), $collectionSize);
}
}
Loading

0 comments on commit c0ae5df

Please sign in to comment.