/** * Verifies that we can filter files from string. */ public function testOnAddFromString() { // only allow one path $this->subscriber->expects(self::exactly(2))->method('isAllowed')->with(self::anything(), false)->willReturnCallback(function ($path) { return 'to/a' === $path; }); // make sure the allowed path is... allowed $event = new PreAddFromStringEvent($this->builder, 'to/a'); $this->subscriber->onAddFromString($event); self::assertFalse($event->isSkipped()); // now make sure that disallowed paths are disallowed $event = new PreAddFromStringEvent($this->builder, 'to/b'); $this->subscriber->onAddFromString($event); self::assertTrue($event->isSkipped()); }