コード例 #1
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     $Folder = new Folder($this->Task->path . 'BakeTestApp');
     $Folder->delete();
     unset($this->Task);
 }
コード例 #2
0
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     unset($this->Task);
     $Folder = new Folder($this->path);
     $Folder->delete();
     Plugin::unload();
 }
コード例 #3
0
ファイル: FileTest.php プロジェクト: ripzappa0924/carte0.0.1
 /**
  * tearDown method
  *
  * @return void
  */
 public function tearDown()
 {
     parent::tearDown();
     $this->File->close();
     unset($this->File);
     $Folder = new Folder();
     $Folder->delete(TMP . 'tests/permissions');
 }
コード例 #4
0
 /**
  * testAddTestDirectoryRecursiveWithNonPhp
  *
  * @return void
  */
 public function testAddTestDirectoryRecursiveWithNonPhp()
 {
     $this->skipIf(!is_writable(TMP), 'Cant addTestDirectoryRecursiveWithNonPhp unless the tmp folder is writable.');
     $Folder = new Folder(TMP . 'MyTestFolder', true, 0777);
     touch($Folder->path . DS . 'BackupTest.php~');
     touch($Folder->path . DS . 'SomeNotesTest.txt');
     touch($Folder->path . DS . 'NotHiddenTest.php');
     $suite = $this->getMock('Cake\\TestSuite\\TestSuite', array('addTestFile'));
     $suite->expects($this->exactly(1))->method('addTestFile');
     $suite->addTestDirectoryRecursive($Folder->pwd());
     $Folder->delete();
 }
コード例 #5
0
 /**
  * Test Execute
  *
  * @return void
  */
 public function testExecuteWithOneArg()
 {
     $this->Task->expects($this->at(0))->method('in')->will($this->returnValue('y'));
     $path = $this->Task->path . 'BakeTestPlugin';
     $file = $path . DS . 'Controller' . DS . 'AppController.php';
     $this->Task->expects($this->at(1))->method('createFile')->with($file, $this->stringContains('class AppController extends BaseController {'));
     $file = $path . DS . 'phpunit.xml';
     $this->Task->expects($this->at(2))->method('createFile')->with($file, new \PHPUnit_Framework_Constraint_IsAnything());
     $file = $path . DS . 'Test' . DS . 'bootstrap.php';
     $this->Task->expects($this->at(3))->method('createFile')->with($file, new \PHPUnit_Framework_Constraint_IsAnything());
     $this->Task->main('BakeTestPlugin');
     $Folder = new Folder($this->Task->path . 'BakeTestPlugin');
     $Folder->delete();
 }
コード例 #6
0
ファイル: ShellTest.php プロジェクト: ripzappa0924/carte0.0.1
 /**
  * setUp method
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->io = $this->getMock('Cake\\Console\\ConsoleIo', [], [], '', false);
     $this->Shell = new ShellTestShell($this->io);
     if (is_dir(TMP . 'shell_test')) {
         $Folder = new Folder(TMP . 'shell_test');
         $Folder->delete();
     }
 }
コード例 #7
0
 /**
  * test item() with enclosure data.
  *
  * @return void
  */
 public function testItemEnclosureLength()
 {
     if (!is_writable(WWW_ROOT)) {
         $this->markTestSkipped('Webroot is not writable.');
     }
     $testExists = is_dir(WWW_ROOT . 'tests');
     $tmpFile = WWW_ROOT . 'tests/cakephp.file.test.tmp';
     $File = new File($tmpFile, true);
     $this->assertTrue($File->write('123'), 'Could not write to ' . $tmpFile);
     clearstatcache();
     $item = array('title' => array('value' => 'My Title', 'cdata' => true), 'link' => 'http://www.example.com/1', 'description' => array('value' => 'descriptive words', 'cdata' => true), 'enclosure' => array('url' => '/tests/cakephp.file.test.tmp'), 'pubDate' => '2008-05-31 12:00:00', 'guid' => 'http://www.example.com/1', 'category' => array(array('value' => 'CakePHP', 'cdata' => true, 'domain' => 'http://www.cakephp.org'), array('value' => 'Bakery', 'cdata' => true)));
     $result = $this->Rss->item(null, $item);
     if (!function_exists('mime_content_type')) {
         $type = null;
     } else {
         $type = mime_content_type($tmpFile);
     }
     $expected = array('<item', '<title', '<![CDATA[My Title]]', '/title', '<link', 'http://www.example.com/1', '/link', '<description', '<![CDATA[descriptive words]]', '/description', 'enclosure' => array('url' => $this->Rss->url('/tests/cakephp.file.test.tmp', true), 'length' => filesize($tmpFile), 'type' => $type), '<pubDate', date('r', strtotime('2008-05-31 12:00:00')), '/pubDate', '<guid', 'http://www.example.com/1', '/guid', 'category' => array('domain' => 'http://www.cakephp.org'), '<![CDATA[CakePHP]]', '/category', '<category', '<![CDATA[Bakery]]', '/category', '/item');
     if ($type === null) {
         unset($expected['enclosure']['type']);
     }
     $this->assertTags($result, $expected);
     $File->delete();
     if (!$testExists) {
         $Folder = new Folder(WWW_ROOT . 'tests');
         $Folder->delete();
     }
 }
コード例 #8
0
 /**
  * testMoveWithSkip method
  *
  * Verify that directories and files are moved recursively
  * even if the destination directory already exists.
  * Subdirectories existing in both destination and source directory
  * are skipped and not merged or overwritten.
  *
  * @return void
  */
 public function testMoveWithSkip()
 {
     extract($this->_setupFilesystem());
     $Folder = new Folder($folderOne);
     $result = $Folder->move(array('to' => $folderTwo, 'scheme' => Folder::SKIP));
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . '/file1.php'));
     $this->assertTrue(is_dir($folderTwo . '/folderB'));
     $this->assertTrue(file_exists($folderTwoB . '/fileB.php'));
     $this->assertFalse(file_exists($fileOne));
     $this->assertFalse(file_exists($folderOneA));
     $this->assertFalse(file_exists($fileOneA));
     $Folder = new Folder($folderTwo);
     $Folder->delete();
     new Folder($folderOne, true);
     new Folder($folderOneA, true);
     new Folder($folderTwo, true);
     touch($fileOne);
     touch($fileOneA);
     $Folder = new Folder($folderOne);
     $result = $Folder->move(array('to' => $folderTwo, 'scheme' => Folder::SKIP));
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . '/file1.php'));
     $this->assertTrue(is_dir($folderTwo . '/folderA'));
     $this->assertTrue(file_exists($folderTwo . '/folderA/fileA.php'));
     $this->assertFalse(file_exists($fileOne));
     $this->assertFalse(file_exists($folderOneA));
     $this->assertFalse(file_exists($fileOneA));
     $Folder = new Folder($folderTwo);
     $Folder->delete();
     new Folder($folderOne, true);
     new Folder($folderOneA, true);
     new Folder($folderTwo, true);
     new Folder($folderTwoB, true);
     touch($fileOne);
     touch($fileOneA);
     file_put_contents($folderTwoB . '/fileB.php', 'untouched');
     $Folder = new Folder($folderOne);
     $result = $Folder->move(array('to' => $folderTwo, 'scheme' => Folder::SKIP));
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . '/file1.php'));
     $this->assertEquals('untouched', file_get_contents($folderTwoB . '/fileB.php'));
     $this->assertFalse(file_exists($fileOne));
     $this->assertFalse(file_exists($folderOneA));
     $this->assertFalse(file_exists($fileOneA));
     $Folder = new Folder($path);
     $Folder->delete();
 }
コード例 #9
0
 /**
  * test fileExistsInPath()
  *
  * @return void
  */
 public function testFileExistsInPath()
 {
     if (!function_exists('ini_set')) {
         $this->markTestSkipped('%s ini_set function not available');
     }
     $_includePath = ini_get('include_path');
     $path = TMP . 'basics_test';
     $folder1 = $path . DS . 'folder1';
     $folder2 = $path . DS . 'folder2';
     $file1 = $path . DS . 'file1.php';
     $file2 = $folder1 . DS . 'file2.php';
     $file3 = $folder1 . DS . 'file3.php';
     $file4 = $folder2 . DS . 'file4.php';
     new Folder($path, true);
     new Folder($folder1, true);
     new Folder($folder2, true);
     touch($file1);
     touch($file2);
     touch($file3);
     touch($file4);
     ini_set('include_path', $path . PATH_SEPARATOR . $folder1);
     $this->assertEquals(fileExistsInPath('file1.php'), $file1);
     $this->assertEquals(fileExistsInPath('file2.php'), $file2);
     $this->assertEquals(fileExistsInPath('folder1' . DS . 'file2.php'), $file2);
     $this->assertEquals(fileExistsInPath($file2), $file2);
     $this->assertEquals(fileExistsInPath('file3.php'), $file3);
     $this->assertEquals(fileExistsInPath($file4), $file4);
     $this->assertFalse(fileExistsInPath('file1'));
     $this->assertFalse(fileExistsInPath('file4.php'));
     $Folder = new Folder($path);
     $Folder->delete();
     ini_set('include_path', $_includePath);
 }