/** * testAppend method * * @return void */ public function testAppend() { if (!($tmpFile = $this->_getTmpFile())) { return false; } if (file_exists($tmpFile)) { unlink($tmpFile); } $TmpFile = new File($tmpFile); $this->assertFalse(file_exists($tmpFile)); $fragments = array('CakePHP\'s', ' test suite', ' was here ...'); $data = null; $size = 0; foreach ($fragments as $fragment) { $r = $TmpFile->append($fragment); $this->assertTrue($r); $this->assertTrue(file_exists($tmpFile)); $data = $data . $fragment; $this->assertEquals($data, file_get_contents($tmpFile)); $newSize = $TmpFile->size(); $this->assertTrue($newSize > $size); $size = $newSize; $TmpFile->close(); } $TmpFile->append(''); $this->assertEquals($data, file_get_contents($tmpFile)); $TmpFile->close(); }
/** * Update the app's bootstrap.php file. * * @param string $plugin Name of plugin * @return void */ protected function _modifyBootstrap($plugin) { $bootstrap = new File($this->bootstrap, false); $contents = $bootstrap->read(); if (!preg_match("@\n\\s*Plugin::loadAll@", $contents)) { $bootstrap->append("\nPlugin::load('{$plugin}', ['bootstrap' => false, 'routes' => false]);\n"); $this->out(''); $this->out(sprintf('%s modified', $this->bootstrap)); } }