Esempio n. 1
0
 /**
  * Test callbacks
  *
  * This test will make sure callbacks are called for each FileInfoInterface
  * object in the correct order.
  */
 public function testCallbacks()
 {
     $this->expectOutputString("BeforeValidate: foo\nAfterValidate: foo\nBeforeValidate: bar\nAfterValidate: bar\nBeforeUpload: foo\nAfterUpload: foo\nBeforeUpload: bar\nAfterUpload: bar\n");
     $callbackBeforeValidate = function (\Upload\FileInfoInterface $fileInfo) {
         echo 'BeforeValidate: ' . $fileInfo->getName(), PHP_EOL;
     };
     $callbackAfterValidate = function (\Upload\FileInfoInterface $fileInfo) {
         echo 'AfterValidate: ' . $fileInfo->getName(), PHP_EOL;
     };
     $callbackBeforeUpload = function (\Upload\FileInfoInterface $fileInfo) {
         echo 'BeforeUpload: ' . $fileInfo->getName(), PHP_EOL;
     };
     $callbackAfterUpload = function (\Upload\FileInfoInterface $fileInfo) {
         echo 'AfterUpload: ' . $fileInfo->getName(), PHP_EOL;
     };
     $file = new \Upload\File('multiple', $this->storage);
     $file->beforeValidate($callbackBeforeValidate);
     $file->afterValidate($callbackAfterValidate);
     $file->beforeUpload($callbackBeforeUpload);
     $file->afterUpload($callbackAfterUpload);
     $file->upload();
 }