/**
  * @test
  */
 public function shouldIterate()
 {
     $collection = $this->createCollection([TeraBytes::allocateUnits(1), GigaBytes::allocateUnits(1), MegaBytes::allocateUnits(1), KiloBytes::allocateUnits(1), Bytes::allocateUnits(1)]);
     $i = 0;
     foreach ($collection as $key => $bytes) {
         $this->assertSame($i, $key);
         $this->assertInstanceOf(Bytes::class, $bytes);
         $i++;
     }
     $this->assertSame(5, $i);
 }
예제 #2
0
 public function listOfAddingUnits()
 {
     return [[KiloBytes::allocateUnits(1), KiloBytes::allocateUnits(1), KiloBytes::allocateUnits(2)], [MegaBytes::allocateUnits(1), MegaBytes::allocateUnits(1), MegaBytes::allocateUnits(2)], [GigaBytes::allocateUnits(1), GigaBytes::allocateUnits(1), GigaBytes::allocateUnits(2)], [TeraBytes::allocateUnits(1), TeraBytes::allocateUnits(1), TeraBytes::allocateUnits(2)], [Bytes::allocateUnits(1), KiloBytes::allocateUnits(1), Bytes::allocateUnits(1025)], [KiloBytes::allocateUnits(1), MegaBytes::allocateUnits(1), KiloBytes::allocateUnits(1025)], [MegaBytes::allocateUnits(1), GigaBytes::allocateUnits(1), MegaBytes::allocateUnits(1025)], [GigaBytes::allocateUnits(1), TeraBytes::allocateUnits(1), GigaBytes::allocateUnits(1025)]];
 }
예제 #3
0
 /**
  * @test
  */
 public function shouldConvertMegaBytesToKiloBytes()
 {
     $bytes = MegaBytes::allocateUnits(1);
     $this->assertEquals($bytes->kiloBytes()->units(), 1 * 1024);
 }
예제 #4
0
 /**
  * @test
  */
 public function shouldBeTrueWhenZeroBytes()
 {
     $this->assertTrue(Bytes::allocateUnits(0)->hasZeroBytes());
     $this->assertTrue(KiloBytes::allocateUnits(0)->hasZeroBytes());
     $this->assertTrue(MegaBytes::allocateUnits(0)->hasZeroBytes());
     $this->assertTrue(GigaBytes::allocateUnits(0)->hasZeroBytes());
     $this->assertTrue(TeraBytes::allocateUnits(0)->hasZeroBytes());
 }