public function testSaveDirectory()
 {
     $directory = new FileDirectory();
     $fileDirectory = FileDirectory::findOne((int) 1);
     $directory->attachBehavior('DirectorySave', array('class' => DirectoryBehavior::className(), 'directoryName' => self::$directoryName, 'directoryPath' => $fileDirectory->path));
     $directory->parent_id = $fileDirectory->id;
     $this->assertTrue($directory->save());
 }
 public function actionCreateDirectory()
 {
     $request = Yii::$app->request;
     $model = new FileDirectory();
     $fileDirectory = FileDirectory::findOne((int) $request->post('parent_id'));
     $model->attachBehavior('DirectorySave', ['class' => DirectoryBehavior::className(), 'directoryName' => $request->post('name'), 'directoryPath' => $fileDirectory->path]);
     if ($request->post('name') !== null) {
         $headers = Yii::$app->response->headers;
         $model->attributes = $request->post();
         $model->parent_id = $fileDirectory->id;
         if ($model->save()) {
             $headers->add('HTTP/1.1 201 Created', '');
         }
         $headers->add('HTTP/1.1 400 Bad request', '');
     }
     if ($request->isAjax) {
         return $this->renderAjax('create_json', ['model' => $model]);
     }
 }