delete() public method

Delete a file from the stack.
public delete ( Bolt\Filesystem\Handler\FileInterface | string $filename )
$filename Bolt\Filesystem\Handler\FileInterface | string
Example #1
0
 public function testSetup()
 {
     $app = $this->getApp();
     $users = $this->getMock('Bolt\\Users', array('getCurrentUser', 'saveUser'), array($app));
     $app['users'] = $users;
     $stack = new Stack($app);
     $stack->add('mytestfile');
     $this->assertTrue($stack->isOnStack('mytestfile'));
     $stack->delete('mytestfile');
     $this->assertFalse($stack->isOnStack('mytestfile'));
     $this->assertFalse($stack->isStackable('mytestfile'));
     $this->assertTrue($stack->isStackable('mytestfile.png'));
 }
Example #2
0
 public function testDelete()
 {
     $count = count($this->stack);
     $this->stack->delete('non_existent_file');
     $this->assertEquals($count, count($this->stack), 'Deleting a non existent file should do nothing');
     $this->stack->delete('files://h.txt');
     $this->assertEquals($count, count($this->stack), 'Deleting a file not on the stack should do nothing');
     $expectedList = ['files://a.jpg', 'files://c.txt', 'files://d.doc', 'files://e.mp3', 'theme://f.txt', 'theme://g.txt'];
     $this->users->expects($this->once())->method('saveUser')->with(['stack' => $expectedList]);
     $this->stack->delete('files://b.txt');
     $this->assertFiles($this->stack->getList(), $expectedList, 'Deleting a file on the stack should remove it');
     $this->assertEquals($expectedList, $this->session->get('stack'), 'Deleting a file on the stack should persist removal to session');
 }