コード例 #1
0
ファイル: BalloonTest.php プロジェクト: raphhh/balloon
 public function testClear()
 {
     $data = [['key1' => 'value1', 'key2' => 'value2'], ['key1' => 'value3', 'key2' => 'value4']];
     $final = [['key1' => 'value1', 'key2' => 'value2']];
     $filePath = __DIR__ . '/resources/data.json';
     file_put_contents($filePath, json_encode($data));
     $balloonFactory = new BalloonFactory();
     $balloon = $balloonFactory->create($filePath);
     $result = $balloon->getAll();
     $this->assertSame($data, $result);
     $result = $balloon->remove(1);
     $this->assertSame(0, $result);
     $result = $balloon->getAll();
     $this->assertSame($final, $result);
     $result = json_decode(file_get_contents($filePath), true);
     $this->assertSame($data, $result);
     $balloon->clear();
     $result = $balloon->flush();
     $this->assertSame(130, $result);
     $result = json_decode(file_get_contents($filePath), true);
     $this->assertSame($data, $result);
 }
コード例 #2
0
 /**
  * @param string $filePath
  * @param string $className
  * @param string $primaryKey
  * @return \Samurai\Module\ModuleManager
  */
 public function create($filePath, $className = 'Samurai\\Module\\Module', $primaryKey = 'name')
 {
     return parent::create($filePath, $className, $primaryKey);
 }
コード例 #3
0
 /**
  * @param Config $config
  * @return AliasManager
  */
 public function createFromConfig(Config $config)
 {
     $balloonFactory = new BalloonFactory();
     return new AliasManager($balloonFactory->create($config['alias.global.path'], 'Samurai\\Alias\\Alias', 'name'), $balloonFactory->create($config['alias.local.path'], 'Samurai\\Alias\\Alias', 'name'));
 }
コード例 #4
0
ファイル: ModuleProcedure.php プロジェクト: raphhh/samurai
 /**
  * @param Module $module
  * @return array
  */
 private function retrieveOriginalModuleData(Module $module)
 {
     return $this->balloonFactory->create($this->buildConfigPath($module))->getAll();
 }