add() public method

Add a file to the stack.
public add ( Bolt\Filesystem\Handler\FileInterface | string $filename, Bolt\Filesystem\Handler\FileInterface &$removed = null ) : Bolt\Filesystem\Handler\FileInterface
$filename Bolt\Filesystem\Handler\FileInterface | string The file to add.
$removed Bolt\Filesystem\Handler\FileInterface Returns the removed file, if one was removed.
return Bolt\Filesystem\Handler\FileInterface If filename cannot be matched to filesystem.
Example #1
0
 public function testListFilter()
 {
     $app = $this->makeApp();
     $app['resources']->setPath('files', PHPUNIT_ROOT . '/resources/stack');
     $app->initialize();
     $users = $this->getMock('Bolt\\Users', array('getCurrentUser', 'saveUser'), array($app));
     $app['users'] = $users;
     $stack = new Stack($app);
     $stack->add('files/testing.md');
     $stack->add('files/testing.txt');
     $stack->add('files/test.jpg');
     $stack->add('files/test2.jpg');
     $items = $stack->listItems(100, 'image');
     $this->assertEquals(2, count($items));
     $items = $stack->listItems(100, 'document');
     $this->assertEquals(2, count($items));
 }
Example #2
0
 public function testAddNonExistentFile()
 {
     $this->setExpectedException(FileNotFoundException::class);
     $this->stack->add('non_existent_file');
 }