Asserts that an array does not have a specified key.
public static assertArrayNotHasKey ( mixed $key, array | ArrayAccess $array, string $message = '' ) | ||
$key | mixed | |
$array | array | ArrayAccess | |
$message | string |
/** * Assert that the response view is missing a piece of bound data. * * @param string $key * @return void */ public function assertViewMissing($key) { if (!isset($this->response->original) || !$this->response->original instanceof View) { return PHPUnit::assertTrue(false, 'The response was not a view.'); } PHPUnit::assertArrayNotHasKey($key, $this->response->original->getData()); }
public function testIncomingInvalidatedTransactionUpdatesLedgerEntries() { $provisional_tx_repository = app('App\\Repositories\\ProvisionalTransactionRepository'); $notification_repository = app('App\\Repositories\\NotificationRepository'); $ledger_entry_repository = app('App\\Repositories\\LedgerEntryRepository'); // setup monitors $payment_address_helper = app('PaymentAddressHelper'); $payment_address_one = $payment_address_helper->createSamplePaymentAddressWithoutInitialBalances(null, ['address' => '1JztLWos5K7LsqW5E78EASgiVBaCe6f7cD']); // receive unconfirmed transactions $parsed_txs = $this->receiveUnconfirmedTransactions(1); // check accounts $account_one = AccountHandler::getAccount($payment_address_one, 'default'); $balance = $ledger_entry_repository->accountBalancesByAsset($account_one, null); PHPUnit::assertEquals(0.004, $balance['unconfirmed']['BTC']); // now confirm a malleated version of the transaction $malleated_tx = $parsed_txs[0]; $malleated_tx['txid'] = str_repeat('0', 54) . 'MALLEATED1'; $malleated_txs = [$malleated_tx]; // now confirm the malleated transaction (with 2 confirmations) $this->sendConfirmationEvents(2, $malleated_txs); // check for invalidation notification $balance = $ledger_entry_repository->accountBalancesByAsset($account_one, null); PHPUnit::assertEquals(0.004, $balance['confirmed']['BTC']); PHPUnit::assertArrayNotHasKey('BTC', $balance['unconfirmed']); }
/** * @test */ public function it_detects_proper_values_and_constants() { $enum = new FakeEnum(); \PHPUnit_Framework_Assert::assertContains('SOME_KEY', $enum->keys()); \PHPUnit_Framework_Assert::assertArrayHasKey('SOME_KEY', $enum->values()); \PHPUnit_Framework_Assert::assertArrayNotHasKey('some-value', $enum->values()); \PHPUnit_Framework_Assert::assertContains('some-value', $enum->values()); \PHPUnit_Framework_Assert::assertSame('SOME_KEY', $enum->getConstantForValue('some-value')); \PHPUnit_Framework_Assert::assertTrue($enum->has('some-value')); \PHPUnit_Framework_Assert::assertFalse($enum->has('SOME-VALUE')); }
/** * Asserts that an array does not have a specified key. * * @param mixed $key * @param array $array * @param string $message * @since Method available since Release 3.0.0 */ function assertArrayNotHasKey($key, array $array, $message = '') { return PHPUnit_Framework_Assert::assertArrayNotHasKey($key, $array, $message); }
public function toHaveKey($key) { if ($this->negate) { a::assertArrayNotHasKey($key, $this->actual); } else { a::assertArrayHasKey($key, $this->actual); } }
public function it_can_receive_due_scheduled_commands() { $date = new \DateTimeImmutable(); $timestamp = $date->getTimestamp(); $lua = $this->getLua('receive_due_messages'); $this->adapter->evalLua($lua, ['test', 0, $timestamp, SchedulerWorker::DEFAULT_THROTTLE])->shouldBeCalled()->willReturn([['test', 'test', 'test', $timestamp]]); $commandsWrapper = $this->receiveDueCommands($date); $commands = $commandsWrapper->getWrappedObject(); \PHPUnit_Framework_Assert::assertArrayHasKey(0, $commands); \PHPUnit_Framework_Assert::assertArrayNotHasKey(1, $commands); \PHPUnit_Framework_Assert::assertEquals('test', $commands[0]->getId()); }
public function hasntKey($key) { a::assertArrayNotHasKey($key, $this->actual, $this->description); }
/** * Expect that an array does not have a specified key. * * @param mixed $key * @param string $message * * @return Expect */ public function notToHaveKey($key, $message = '') { Assert::assertArrayNotHasKey($key, $this->value, $message); return $this; }
public function arrayToNotHaveKey($key) { \PHPUnit_Framework_Assert::assertArrayNotHasKey($key, $this->actual); }
/** * @Then /^in the response there is no field called "([^"]*)"$/ * @param string $name * @return void * @throws \Exception */ public function theResponseShouldNotHaveAField($name) { Assertions::assertArrayNotHasKey($name, $this->getResponseData()); }
/** * @Then /^there should not be "([^"]*)" parameter$/ */ public function thereShouldNotBeParameter($key) { \PHPUnit_Framework_Assert::assertArrayNotHasKey($key, $this->containerParameters); }
/** * @param $key * @param $actual * @param $description */ protected function assertArrayNotHasKey($key, $actual, $description) { \PHPUnit_Framework_Assert::assertArrayNotHasKey($key, $actual, $description); }