/** * Test various operations. * * @return void */ public function testAll() { $environment = $this->mockEnvironment(); $clipboard = new Clipboard(); $filterGetAll = new Filter(); $createItem = new UnsavedItem(Item::CREATE, null, 'dummy-provider'); $this->assertTrue($clipboard->isEmpty($filterGetAll)); $this->assertFalse($clipboard->isNotEmpty($filterGetAll)); $clipboard->push($createItem); $this->assertFalse($clipboard->isEmpty($filterGetAll)); $this->assertTrue($clipboard->isNotEmpty($filterGetAll)); $this->assertTrue($clipboard->has($createItem)); $this->assertTrue($clipboard->has(clone $createItem)); $clipboard2 = new Clipboard(); $clipboard->saveTo($environment); $clipboard2->loadFrom($environment); $this->assertTrue($clipboard2->has($createItem)); $this->assertTrue($clipboard2->has(clone $createItem)); }
/** * Test remove() method. * * @return void */ public function testRemoveRemovesOnlyOneOfModel() { $modelId = ModelId::fromValues('dummy-provider', '15'); $otherModelId = ModelId::fromValues('dummy-provider', '16'); $clipboard = new Clipboard(); $filterGetAll = new Filter(); $cutItem = new Item(Item::CUT, null, $modelId); $copyItem = new Item(Item::COPY, null, $modelId); $copyOtherItem = new Item(Item::COPY, null, $otherModelId); $clipboard->push($cutItem); $clipboard->push($copyItem); $clipboard->push($copyOtherItem); $clipboard->remove($copyItem); $this->assertTrue($clipboard->hasId($modelId)); $this->assertTrue($clipboard->hasId($otherModelId)); $items = $clipboard->fetch($filterGetAll); $this->assertCount(2, $items); $this->assertArraySubset([$cutItem, $copyOtherItem], $items); }