public function testOnlyAllowedKeysCanBeRead() { $collection = new Collection(); $collection->setAllowedKeys('allowed_key'); $this->assertNull($collection['allowed_key']); $this->expectsException(function () use($collection) { $collection['illegal_key']; }, Exception::class, null, Exception::COLLECTION_FORBIDDEN_KEY); }