Laravel Hetzner Storagebox

PHP MIT

Production-ready Laravel package for integrating Hetzner Storage Box into Laravel applications using the native Storage facade and filesystem API.

Stars
19
Forks
0
Downloads
2,357
Open Issues
0
Files main

Repository Files

Loading file structure...
tests/Unit/CollectionTest.php
<?php

namespace GhostCompiler\Hetzner\StorageBox\Tests\Unit;

use GhostCompiler\Hetzner\StorageBox\Collections\StorageBoxCollection;
use GhostCompiler\Hetzner\StorageBox\Collections\StorageBoxTypeCollection;
use GhostCompiler\Hetzner\StorageBox\DTOs\StorageBox;
use GhostCompiler\Hetzner\StorageBox\DTOs\StorageBoxType;
use GhostCompiler\Hetzner\StorageBox\Tests\TestCase;

class CollectionTest extends TestCase
{
    public function test_storage_box_collection()
    {
        $box1 = StorageBox::fromArray(['id' => 1, 'name' => 'box-1']);
        $box2 = StorageBox::fromArray(['id' => 2, 'name' => 'box-2']);

        $col = new StorageBoxCollection([$box1, $box2]);

        $this->assertCount(2, $col);
        $this->assertEquals('box-1', $col->first()->name);
        $this->assertEquals(2, $col->last()->id);
    }

    public function test_storage_box_type_collection()
    {
        $type1 = StorageBoxType::fromArray(['id' => 1, 'name' => 'bx11']);
        $col = new StorageBoxTypeCollection([$type1]);

        $this->assertCount(1, $col);
        $this->assertEquals('bx11', $col->first()->name);
    }
}