diff --git a/.phpunit.result.cache b/.phpunit.result.cache index a2b6887..868c22c 100644 --- a/.phpunit.result.cache +++ b/.phpunit.result.cache @@ -1 +1 @@ -C:37:"PHPUnit\Runner\DefaultTestResultCache":947:{a:2:{s:7:"defects";a:7:{s:49:"Padam87\BinPacker\Tests\BinPackerTest::testSimple";i:4;s:51:"Padam87\BinPacker\Tests\BinPackerTest::testRotation";i:3;s:51:"Padam87\BinPacker\Tests\BinPackerTest::testOverflow";i:3;s:49:"Padam87\BinPacker\Tests\BinPackerTest::testGrowth";i:3;s:50:"Padam87\BinPacker\Tests\VisualizerTest::testSimple";i:5;s:54:"Padam87\BinPacker\Tests\VisualizerTest::testStepByStep";i:5;s:52:"Padam87\BinPacker\Tests\GifMakerTest::testStepByStep";i:4;}s:5:"times";a:7:{s:49:"Padam87\BinPacker\Tests\BinPackerTest::testSimple";d:0.003;s:51:"Padam87\BinPacker\Tests\BinPackerTest::testRotation";d:0;s:51:"Padam87\BinPacker\Tests\BinPackerTest::testOverflow";d:0.009;s:49:"Padam87\BinPacker\Tests\BinPackerTest::testGrowth";d:0.01;s:50:"Padam87\BinPacker\Tests\VisualizerTest::testSimple";d:0.116;s:54:"Padam87\BinPacker\Tests\VisualizerTest::testStepByStep";d:0.232;s:52:"Padam87\BinPacker\Tests\GifMakerTest::testStepByStep";d:3.206;}}} \ No newline at end of file +{"version":1,"defects":[],"times":{"Padam87\\BinPacker\\Tests\\BinPackerTest::testSimple":0.237,"Padam87\\BinPacker\\Tests\\BinPackerTest::testRotation":0.011,"Padam87\\BinPacker\\Tests\\BinPackerTest::testRotationStatus":0,"Padam87\\BinPacker\\Tests\\BinPackerTest::testOverflow":0.021,"Padam87\\BinPacker\\Tests\\BinPackerTest::testGrowth":0.024}} \ No newline at end of file diff --git a/src/Model/Block.php b/src/Model/Block.php index 6943d98..b4c120b 100644 --- a/src/Model/Block.php +++ b/src/Model/Block.php @@ -19,6 +19,11 @@ class Block */ private $rotatable; + /** + * @var bool + */ + private $rotated = false; + /** * An ID or name to identify the block for your own purposes. * @@ -76,6 +81,11 @@ public function isRotatable(): ?bool return $this->rotatable; } + public function isRotated() + { + return $this->rotated; + } + public function setRotatable(?bool $rotatable): self { $this->rotatable = $rotatable; @@ -106,6 +116,8 @@ public function rotate(): self $this->setWidth($this->getHeight()); $this->setHeight($w); + $this->rotated = !$this->rotated; + return $this; } diff --git a/tests/Functional/BinPackerTest.php b/tests/Functional/BinPackerTest.php index 74dcac1..3410742 100644 --- a/tests/Functional/BinPackerTest.php +++ b/tests/Functional/BinPackerTest.php @@ -46,6 +46,22 @@ public function testRotation() $this->assertFalse($nonRotatable->getNode() && $nonRotatable->getNode()->isUsed()); } + public function testRotationStatus() + { + $bin = new Bin(2000, 100); + + $rotatable = new Block(100, 1000); + + $blocks = [$rotatable]; + + $packer = new BinPacker(); + + $blocks = $packer->pack($bin, $blocks); + + $this->assertTrue($rotatable->getNode() && $rotatable->isRotated()); + + } + public function testOverflow() { $bin = new Bin(1000, 1000);