Example #1
0
 /**
  * ページファイルを削除する
  * 
  * @param array $name ページ名
  * @param array $categoryId ページカテゴリーID
  * @param array $expected 期待値
  * @param string $message テストが失敗した時に表示されるメッセージ
  * @dataProvider delFileDataProvider
  */
 public function testDelFile($name, $categoryId, $expected, $message = null)
 {
     $data = array('Page' => array('contents' => ''), 'Content' => array('name' => $name, 'parent_id' => $categoryId, 'site_id' => 0, 'title' => ''));
     $path = $this->Page->getPageFilePath($data);
     $File = new File($path);
     // 存在するファイルパスか
     if ($File->exists()) {
         // 削除したファイルを再生成するため内容取得
         $tmp_content = $File->read();
         // ファイル削除
         $this->Page->delFile($data);
         // trueなら削除済み
         $result = !file_exists($path);
         // 削除したファイルを再生成
         $File->write($tmp_content);
     } else {
         $result = $this->Page->delFile($data);
     }
     $File->close();
     $this->assertEquals($expected, $result, $message);
 }