Funzione PHPUnit | AssertDirectoryIsReadable()

| | | | | | | | | | | | | |
Sintassi:
assertDirectoryIsReadable (intero $directory, stringa $messaggio = ``) 
Parametri: questa funzione accetta due parametri come mostrato nella sintassi precedente. I parametri sono descritti di seguito:
  • $directory: questo parametro è una stringa che rappresenta il percorso della directory.
  • $message: questo parametro accetta un valore stringa. Quando il test case ha avuto esito negativo, questo messaggio stringa è stato visualizzato come messaggio di errore.
I seguenti programmi illustrano la funzione assertDirectoryIsReadable() in PHPUnit: Programma 1: < tr> usa PHPUnitFrameworkTestCase; class GeeksPhpunitTestCase estende TestCase { pubblico funzione testNegativeTestcaseForAssertDirectoryIsReadable() { $directoryPath = " / home / shivam / Documenti / phpunit / notreadable " ; // Assegna una funzione per verificare se il dato // il percorso della directory esiste ed è leggibile $this -> assertDirectoryIsReadable ( $directoryPath , " directoryPath esiste e leggibile " < codice>); } }
?> Output:
PHPUnit 8.2.5 di Sebastian Bergmann e contributori. F 1/1 (100%) Tempo: 89 ms, Memoria: 10,00 MB Si è verificato 1 errore: 1) GeeksPhpunitTestCase::testNegativeTestcaseForAssertDirectoryIsReadable directoryPath esiste e leggibile Impossibile affermare che la directory "/ home / shivam / Documents / engineer / pgp" esiste. /home/shivam/Documents/engineer/phpunit/abc.php:13 FALLIMENTI! Test: 1, Affermazioni: 1, Errori: 1. 
Programma 2: usa PHPUnitFrameworkTestCase; class GeeksPhpunitTestCase estende TestCase { pubblico funzione testPositiveTestcaseForAssertDirectoryIsReadable() { $directoryPath = " / home / shivam / Documenti / ingegnere " ; // Assegna una funzione per verificare se // il percorso della directory esiste e leggibile $this -> assertDirectoryIsReadable ( $directoryPath , "directoryPath esiste e leggibile" ); } }
?>
< b>Output:
PHPUnit 8.2.5 di Sebastian Bergmann e collaboratori. ... 1/1 (100%) Tempo: 67 ms, Memoria: 10,00 MB OK (1 test, 1 asserzione) 
Nota: Per eseguire testcase con PHPUnit i passaggi seguono da qui . Inoltre, assertDirectoryIsReadable() è supportato da phpunit 7 e versioni successive.