PayPal\Test\Functional\Api\InvoiceFunctionalTest::testGetAll PHP Method

testGetAll() public method

public testGetAll ( $invoice ) : Invoice
$invoice Invoice
return PayPal\Api\Invoice
    public function testGetAll($invoice)
    {
        $result = Invoice::getAll(array('page_size' => '20', 'total_count_required' => 'true'), $this->apiContext, $this->mockPayPalRestCall);
        $this->assertNotNull($result);
        $this->assertNotNull($result->getTotalCount());
        $totalPages = ceil($result->getTotalCount() / 20);
        $found = false;
        $foundObject = null;
        do {
            foreach ($result->getInvoices() as $obj) {
                if ($obj->getId() == $invoice->getId()) {
                    $found = true;
                    $foundObject = $obj;
                    break;
                }
            }
            if (!$found) {
                $result = Invoice::getAll(array('page' => --$totalPages, 'page_size' => '20', 'total_required' => 'yes'), $this->apiContext, $this->mockPayPalRestCall);
            }
        } while ($totalPages > 0 && $found == false);
        $this->assertTrue($found, "The Created Invoice was not found in the get list");
        $this->assertEquals($invoice->getId(), $foundObject->getId());
    }