public function testDeleteDirectory() { $source_folder = dirname(__FILE__) . '/test-data/test-parent-directory'; $destination_folder = dirname(__FILE__) . '/test-data/copyed-directory'; $copy_options = array('mode' => 'debug'); CK101Utility::copy_directory($source_folder, $destination_folder, $copy_options); $delete_options = array('mode' => 'debug'); CK101Utility::delete_directory($destination_folder, $delete_options); $copy_parent_folder_exist = file_exists($destination_folder); $copy_file1_exist = file_exists($destination_folder . '/images1.png'); $copy_sub_folder_exist = file_exists($destination_folder . '/test-sub-directory'); $copy_file2_exist = file_exists($destination_folder . '/test-sub-directory/images2.png'); $this->assertEquals(false, $copy_parent_folder_exist); $this->assertEquals(false, $copy_file1_exist); $this->assertEquals(false, $copy_sub_folder_exist); $this->assertEquals(false, $copy_file2_exist); // source is file $source_folder = dirname(__FILE__) . '/test-data/test-parent-directory/images1.png'; $destination_folder = dirname(__FILE__) . '/test-data/copyed-directory'; $copy_options = array('mode' => 'debug'); CK101Utility::copy_directory($source_folder, $destination_folder, $copy_options); $delete_options = array('mode' => 'debug'); CK101Utility::delete_directory($destination_folder, $delete_options); $copy_file_exist = file_exists($destination_folder); $this->assertEquals(false, $copy_file_exist); }
/** * ck101_install.php * * PHP version 5 * * @category PHP * @package / * @author Fukuball Lin <*****@*****.**> * @license MIT Licence * @version Release: <0.0.1> * @link https://github.com/fukuball/iloveck101 */ require_once dirname(__FILE__) . "/src/class/CK101Utility.php"; $ck101_cmd_path = '/usr/local/bin/iloveck101'; $source_cmd_path = '/Library/Fuku-PHP/iloveck101/iloveck101.php'; $source_folder = dirname(__FILE__) . '/src'; $destination_folder = '/Library/Fuku-PHP/iloveck101'; echo "Install iloveck101 from {$source_folder} to {$destination_folder} ...\n"; if (file_exists($ck101_cmd_path)) { unlink($ck101_cmd_path); } $copy_options = array('mode' => 'debug'); if (CK101Utility::copy_directory($source_folder, $destination_folder, $copy_options)) { symlink($source_cmd_path, $ck101_cmd_path); chmod($source_cmd_path, 0755); chmod($ck101_cmd_path, 0755); echo "Install success ...\n"; } else { echo "Install fail ...\n"; }