PHPUnit_Framework_Assert::assertNull PHP Method

assertNull() public static method

Asserts that a variable is null.
public static assertNull ( mixed $actual, string $message = '' )
$actual mixed
$message string
    public static function assertNull($actual, $message = '')
    {
        static::assertThat($actual, static::isNull(), $message);
    }

Usage Example

Esempio n. 1
0
 public function testPruneOldTransactions()
 {
     $tx_helper = app('SampleTransactionsHelper');
     $created_txs = [];
     for ($i = 0; $i < 5; $i++) {
         $created_txs[] = $tx_helper->createSampleTransaction('sample_xcp_parsed_01.json', ['txid' => str_repeat('0', 63) . ($i + 1)]);
     }
     $tx_repository = app('App\\Repositories\\TransactionRepository');
     $created_txs[0]->timestamps = false;
     $tx_repository->update($created_txs[0], ['updated_at' => time() - 60], ['timestamps' => false]);
     $created_txs[1]->timestamps = false;
     $tx_repository->update($created_txs[1], ['updated_at' => time() - 59], ['timestamps' => false]);
     $created_txs[2]->timestamps = false;
     $tx_repository->update($created_txs[2], ['updated_at' => time() - 5], ['timestamps' => false]);
     // prune all
     $this->dispatch(new PruneTransactions(50));
     // check that all transactions were erased
     $tx_repository = app('App\\Repositories\\TransactionRepository');
     foreach ($created_txs as $offset => $created_tx) {
         $loaded_tx = $tx_repository->findByTXID($created_tx['txid']);
         if ($offset < 2) {
             PHPUnit::assertNull($loaded_tx, "found unexpected tx: " . ($loaded_tx ? json_encode($loaded_tx->toArray(), 192) : 'null'));
         } else {
             PHPUnit::assertNotNull($loaded_tx, "missing tx {$offset}");
             PHPUnit::assertEquals($created_tx->toArray(), $loaded_tx->toArray());
         }
     }
 }
All Usage Examples Of PHPUnit_Framework_Assert::assertNull
PHPUnit_Framework_Assert