本文整理汇总了PHP中PHPUnit_Framework_Assert::assertCount方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_Assert::assertCount方法的具体用法?PHP PHPUnit_Framework_Assert::assertCount怎么用?PHP PHPUnit_Framework_Assert::assertCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_Assert
的用法示例。
在下文中一共展示了PHPUnit_Framework_Assert::assertCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertErrorsAreTriggered
/**
* @param int $expectedType Expected triggered error type (pass one of PHP's E_* constants)
* @param string[] $expectedMessages Expected error messages
* @param callable $testCode A callable that is expected to trigger the error messages
*/
public static function assertErrorsAreTriggered($expectedType, $expectedMessages, $testCode)
{
if (!is_callable($testCode)) {
throw new \InvalidArgumentException(sprintf('The code to be tested must be a valid callable ("%s" given).', gettype($testCode)));
}
$e = null;
$triggeredMessages = array();
try {
$prevHandler = set_error_handler(function ($type, $message, $file, $line, $context) use($expectedType, &$triggeredMessages, &$prevHandler) {
if ($expectedType !== $type) {
return null !== $prevHandler && call_user_func($prevHandler, $type, $message, $file, $line, $context);
}
$triggeredMessages[] = $message;
});
call_user_func($testCode);
} catch (\Exception $e) {
} catch (\Throwable $e) {
}
restore_error_handler();
if (null !== $e) {
throw $e;
}
\PHPUnit_Framework_Assert::assertCount(count($expectedMessages), $triggeredMessages);
foreach ($triggeredMessages as $i => $message) {
\PHPUnit_Framework_Assert::assertContains($expectedMessages[$i], $message);
}
}
示例2: assertCacheCollectedData
/**
* @param CacheCollectedData[] $expectedCollectedData
* @param CacheCollectedData[] $actualCollectedData
*/
protected function assertCacheCollectedData(array $expectedCollectedData, array $actualCollectedData)
{
Assert::assertCount(count($expectedCollectedData), $actualCollectedData);
foreach ($expectedCollectedData as $key => $expectedItem) {
$this->assertSingleCacheCollectedData($expectedItem, $actualCollectedData[$key]);
}
}
示例3: testProcess
public function testProcess()
{
if (!class_exists(TransactionMiddleware::class)) {
$this->markTestSkipped('"league/tactician-doctrine" is not installed');
}
$this->container->shouldReceive('hasParameter')->with('doctrine.entity_managers')->once()->andReturn(true);
$this->container->shouldReceive('getParameter')->with('doctrine.entity_managers')->once()->andReturn(['default' => 'doctrine.orm.default_entity_manager', 'second' => 'doctrine.orm.second_entity_manager']);
$this->container->shouldReceive('getParameter')->with('doctrine.default_entity_manager')->once()->andReturn('default');
$this->container->shouldReceive('setDefinition')->andReturnUsing(function ($name, Definition $def) {
\PHPUnit_Framework_Assert::assertEquals('tactician.middleware.doctrine.default', $name);
\PHPUnit_Framework_Assert::assertEquals(TransactionMiddleware::class, $def->getClass());
\PHPUnit_Framework_Assert::assertCount(1, $def->getArguments());
\PHPUnit_Framework_Assert::assertInstanceOf(Reference::class, $def->getArgument(0));
\PHPUnit_Framework_Assert::assertEquals('doctrine.orm.default_entity_manager', (string) $def->getArgument(0));
})->once();
$this->container->shouldReceive('setDefinition')->andReturnUsing(function ($name, Definition $def) {
\PHPUnit_Framework_Assert::assertEquals('tactician.middleware.doctrine.second', $name);
\PHPUnit_Framework_Assert::assertEquals(TransactionMiddleware::class, $def->getClass());
\PHPUnit_Framework_Assert::assertCount(1, $def->getArguments());
\PHPUnit_Framework_Assert::assertInstanceOf(Reference::class, $def->getArgument(0));
\PHPUnit_Framework_Assert::assertEquals('doctrine.orm.second_entity_manager', (string) $def->getArgument(0));
})->once();
$this->container->shouldReceive('setDefinition')->with('tactician.middleware.doctrine.second')->once();
$this->container->shouldReceive('setAlias')->once()->with('tactician.middleware.doctrine', 'tactician.middleware.doctrine.default');
$this->compiler->process($this->container);
}
示例4: testMultiplePaymentAddressSendsWithSameClientGUID
public function testMultiplePaymentAddressSendsWithSameClientGUID()
{
// mock the xcp sender
$mock_calls = app('CounterpartySenderMockBuilder')->installMockCounterpartySenderDependencies($this->app, $this);
$user = app('\\UserHelper')->createSampleUser();
$payment_address = app('\\PaymentAddressHelper')->createSamplePaymentAddress($user);
// create a send with a client guid
$api_tester = $this->getAPITester();
$posted_vars = $this->sendHelper()->samplePostVars();
$posted_vars['requestId'] = 'request001';
$expected_created_resource = ['id' => '{{response.id}}', 'destination' => '{{response.destination}}', 'destinations' => '', 'asset' => 'TOKENLY', 'sweep' => '{{response.sweep}}', 'quantity' => '{{response.quantity}}', 'txid' => '{{response.txid}}', 'requestId' => 'request001'];
$loaded_resource_model = $api_tester->testAddResource($posted_vars, $expected_created_resource, $payment_address['uuid']);
// get_asset_info followed by the send
PHPUnit::assertCount(1, $mock_calls['btcd']);
// validate that a mock send was triggered
$send_details = app('TransactionComposerHelper')->parseCounterpartyTransaction($mock_calls['btcd'][0]['args'][0]);
PHPUnit::assertEquals('1JztLWos5K7LsqW5E78EASgiVBaCe6f7cD', $send_details['destination']);
PHPUnit::assertEquals(CurrencyUtil::valueToSatoshis(100), $send_details['quantity']);
PHPUnit::assertEquals('TOKENLY', $send_details['asset']);
// try the send again with the same request_id
$expected_resource = $loaded_resource_model;
$posted_vars = $this->sendHelper()->samplePostVars();
$posted_vars['requestId'] = 'request001';
$loaded_resource_model_2 = $api_tester->testAddResource($posted_vars, $expected_created_resource, $payment_address['uuid']);
// does not send again
PHPUnit::assertCount(1, $mock_calls['btcd']);
// second send resource is the same as the first
PHPUnit::assertEquals($loaded_resource_model, $loaded_resource_model_2);
}
示例5: testInitialFindMissingBlocks
public function testInitialFindMissingBlocks()
{
// init mocks
app('CounterpartySenderMockBuilder')->installMockCounterpartySenderDependencies($this->app, $this);
$blockchain_store = $this->app->make('App\\Blockchain\\Block\\BlockChainStore');
$block_events = $blockchain_store->loadMissingBlockEventsFromBitcoind('BLOCKHASH04');
PHPUnit::assertCount(1, $block_events);
}
示例6: assertions
function assertions($array, $count = 1)
{
PHPUnit_Framework_Assert::assertCount($count, $array);
PHPUnit_Framework_Assert::assertTrue($array['foo'] === 'bar');
PHPUnit_Framework_Assert::assertTrue($array['Foo'] === 'bar');
PHPUnit_Framework_Assert::assertTrue($array['FOo'] === 'bar');
PHPUnit_Framework_Assert::assertTrue($array['FOO'] === 'bar');
}
示例7: it_can_be_added_to_faker_as_a_provider_and_used
/** @test */
public function it_can_be_added_to_faker_as_a_provider_and_used()
{
$faker = Factory::create();
$faker->addProvider(new BuzzwordJobProvider($faker));
$jobTitle = $faker->jobTitle();
$jobTitleWords = explode(' ', $jobTitle);
Assert::assertCount(3, $jobTitleWords);
}
示例8: assertions
function assertions($array, $count = 1)
{
PHPUnit_Framework_Assert::assertCount($count, $array);
PHPUnit_Framework_Assert::assertEquals('bar', $array['foo']);
PHPUnit_Framework_Assert::assertEquals('bar', $array['Foo']);
PHPUnit_Framework_Assert::assertEquals('bar', $array['FOo']);
PHPUnit_Framework_Assert::assertEquals('bar', $array['FOO']);
}
示例9: processAssert
/**
* Assert that first item in grid is not the same on ascending and descending sorting
*
* @param array $results
*/
public function processAssert(array $results)
{
foreach ($results as $itemId => $ids) {
\PHPUnit_Framework_Assert::assertCount(1, $ids, sprintf('Full text search should find only %s item. Following items displayed: %s', $itemId, implode(', ', $ids)));
$actualItemId = $ids[0];
\PHPUnit_Framework_Assert::assertEquals($itemId, $actualItemId, sprintf('%d item is displayed instead of %d after full text search', $actualItemId, $itemId));
}
}
示例10: processAssert
/**
* Assert that first item in grid is not the same on ascending and descending sorting
*
* @param array $filterResults
*/
public function processAssert(array $filterResults)
{
foreach ($filterResults as $itemId => $filters) {
foreach ($filters as $filterName => $ids) {
\PHPUnit_Framework_Assert::assertCount(1, $ids, sprintf('Filtering by "%s" should result in only item id "%d" displayed. %s items ids present', $itemId, $filterName, implode(', ', $ids)));
$actualItemId = $ids[0];
\PHPUnit_Framework_Assert::assertEquals($itemId, $actualItemId, sprintf('%d item is displayed instead of %d after applying "%s" filter', $actualItemId, $itemId, $filterName));
}
}
}
示例11: theConsoleOutputShouldHaveLinesEndingIn
/**
* @Then /^the console output should have lines ending in:$/
*/
public function theConsoleOutputShouldHaveLinesEndingIn(PyStringNode $string)
{
$stdOutLines = explode(PHP_EOL, $this->lastBehatStdOut);
$expectedLines = $string->getLines();
\PHPUnit_Framework_Assert::assertCount(count($expectedLines), $stdOutLines);
foreach ($stdOutLines as $idx => $stdOutLine) {
$suffix = isset($expectedLines[$idx]) ? $expectedLines[$idx] : '(NONE)';
$constraint = \PHPUnit_Framework_Assert::stringEndsWith($suffix);
$constraint->evaluate($stdOutLine);
}
}
示例12: testAPIGetBalances
public function testAPIGetBalances()
{
// sample user for Auth
$sample_user = app('UserHelper')->createSampleUser();
$address = app('PaymentAddressHelper')->createSamplePaymentAddressWithoutDefaultAccount($sample_user);
// add noise
$sample_user_2 = app('UserHelper')->newRandomUser();
$address_2 = app('PaymentAddressHelper')->createSamplePaymentAddressWithoutDefaultAccount($sample_user_2);
app('AccountHelper')->newSampleAccount($address_2);
app('AccountHelper')->newSampleAccount($address_2, 'address 2');
// create 2 models
$api_test_helper = $this->getAPITestHelper($address);
$created_accounts = [];
$created_accounts[] = $api_test_helper->newModel();
$created_accounts[] = $api_test_helper->newModel();
$inactive_account = app('AccountHelper')->newSampleAccount($address, ['name' => 'Inactive 1', 'active' => 0]);
// add balances to each
$txid = 'deadbeef00000000000000000000000000000000000000000000000000000001';
$repo = app('App\\Repositories\\LedgerEntryRepository');
$repo->addCredit(11, 'BTC', $created_accounts[0], LedgerEntry::CONFIRMED, LedgerEntry::DIRECTION_RECEIVE, $txid);
$repo->addCredit(20, 'BTC', $created_accounts[1], LedgerEntry::CONFIRMED, LedgerEntry::DIRECTION_RECEIVE, $txid);
$repo->addDebit(1, 'BTC', $created_accounts[0], LedgerEntry::CONFIRMED, LedgerEntry::DIRECTION_RECEIVE, $txid);
$repo->addCredit(4, 'BTC', $created_accounts[0], LedgerEntry::UNCONFIRMED, LedgerEntry::DIRECTION_RECEIVE, $txid);
$repo->addCredit(5, 'BTC', $created_accounts[1], LedgerEntry::UNCONFIRMED, LedgerEntry::DIRECTION_RECEIVE, $txid);
// now get all the accounts
$api_response = $api_test_helper->callAPIAndValidateResponse('GET', '/api/v1/accounts/balances/' . $address['uuid'] . '');
PHPUnit::assertCount(2, $api_response);
PHPUnit::assertEquals($created_accounts[0]['uuid'], $api_response[0]['id']);
// check balances
PHPUnit::assertEquals(['BTC' => 10], $api_response[0]['balances']['confirmed']);
PHPUnit::assertEquals(['BTC' => 20], $api_response[1]['balances']['confirmed']);
PHPUnit::assertEquals(['BTC' => 4], $api_response[0]['balances']['unconfirmed']);
PHPUnit::assertEquals(['BTC' => 5], $api_response[1]['balances']['unconfirmed']);
// get by name
$api_response = $api_test_helper->callAPIAndValidateResponse('GET', '/api/v1/accounts/balances/' . $address['uuid'] . '?name=Address 1');
PHPUnit::assertCount(1, $api_response);
PHPUnit::assertEquals($created_accounts[0]['uuid'], $api_response[0]['id']);
PHPUnit::assertEquals(['BTC' => 10], $api_response[0]['balances']['confirmed']);
// get inactive
$api_response = $api_test_helper->callAPIAndValidateResponse('GET', '/api/v1/accounts/balances/' . $address['uuid'] . '?active=false');
PHPUnit::assertCount(1, $api_response);
PHPUnit::assertEquals($inactive_account['uuid'], $api_response[0]['id']);
// get by type
$api_response = $api_test_helper->callAPIAndValidateResponse('GET', '/api/v1/accounts/balances/' . $address['uuid'] . '?type=unconfirmed');
PHPUnit::assertCount(2, $api_response);
PHPUnit::assertEquals(['BTC' => 4], $api_response[0]['balances']);
PHPUnit::assertEquals(['BTC' => 5], $api_response[1]['balances']);
$api_response = $api_test_helper->callAPIAndValidateResponse('GET', '/api/v1/accounts/balances/' . $address['uuid'] . '?type=confirmed');
PHPUnit::assertCount(2, $api_response);
PHPUnit::assertEquals(['BTC' => 10], $api_response[0]['balances']);
PHPUnit::assertEquals(['BTC' => 20], $api_response[1]['balances']);
}
示例13: testFindUserWithWebhookEndpoint
public function testFindUserWithWebhookEndpoint()
{
// insert
$user_repo = $this->app->make('App\\Repositories\\UserRepository');
$created_user_model = $user_repo->create($this->app->make('\\UserHelper')->sampleDBVars());
// load from repo
$users = $user_repo->findWithWebhookEndpoint();
PHPUnit::assertNotEmpty($users);
PHPUnit::assertCount(1, $users);
foreach ($users as $user) {
break;
}
PHPUnit::assertEquals('TESTAPITOKEN', $user['apitoken']);
}
示例14: thereShouldBeEntities
/**
* @Then /^the database should contain (\d+) "([^"]*)" entities$/
*/
public function thereShouldBeEntities($nbr, $class)
{
switch ($class) {
case 'dummy':
$repository = $this->entityManager->getRepository('TestBundle:Dummy');
break;
case 'another_dummy':
$repository = $this->entityManager->getRepository('TestBundle:AnotherDummy');
break;
default:
throw new \UnexpectedValueException(sprintf('Unknown %s entity', $class));
}
PHPUnit::assertCount((int) $nbr, $repository->findAll());
}
示例15: testFindMissingBlocks
public function testFindMissingBlocks()
{
// init mocks
app('CounterpartySenderMockBuilder')->installMockCounterpartySenderDependencies($this->app, $this);
// insert
$created_block_model_1 = $this->blockHelper()->createSampleBlock('default_parsed_block_01.json', ['hash' => 'BLOCKHASH01BASE01', 'height' => 333000, 'parsed_block' => ['height' => 333000]]);
$created_block_model_2 = $this->blockHelper()->createSampleBlock('default_parsed_block_01.json', ['hash' => 'BLOCKHASH02', 'previousblockhash' => 'BLOCKHASH01BASE01', 'height' => 333001, 'parsed_block' => ['height' => 333001]]);
// MISSING BLOCKHASH03 and BLOCKHASH04
$created_block_model_3 = $this->blockHelper()->createSampleBlock('default_parsed_block_01.json', ['hash' => 'BLOCKHASH05', 'previousblockhash' => 'BLOCKHASH04', 'height' => 333004, 'parsed_block' => ['height' => 333004]]);
$blockchain_store = $this->app->make('App\\Blockchain\\Block\\BlockChainStore');
$block_events = $blockchain_store->loadMissingBlockEventsFromBitcoind('BLOCKHASH04', 4);
PHPUnit::assertCount(2, $block_events);
// make sure they were loaded in the correct order
PHPUnit::assertEquals(['BLOCKHASH03', 'BLOCKHASH04'], [$block_events[0]['hash'], $block_events[1]['hash']]);
}