public function testTransformOnce() { $count = 0; $transformer = new CallbackTransformer(function () use($count) { return new StringResource('bar' . ++$count); }); $resource = new StringResource('foo'); $collection = new ResourceCollection([$resource]); $collection->addTransformer($transformer); $transformed = $collection->pop(); $this->assertSame('bar1', $transformed->getFile()->fgets()); // add the same resource again $collection->push($resource); $transformed = $collection->pop(); $this->assertSame('foo', $transformed->getFile()->fgets(), 'A resource only gets transformed once'); }