public function testConfigArrayStoredCorrectlyAsYAMLAndHasValidData() { $array = ['account' => ['user' => ['username' => 'Lamonte', 'age' => 25], 'posts' => 12345]]; $savePath = __DIR__ . $this->tempFile; $arrayObject = new ConfigArray($array); $storeArray = new Storage\YAML(dirname($savePath)); $storeArray->store(basename($savePath), (array) $arrayObject); $configLoader = new ConfigLoader(new Loader\YAML(dirname($savePath))); $data = $configLoader->getArrayObject(basename($savePath)); $this->assertTrue($data == $arrayObject); $this->assertTrue(file_exists($savePath)); }
public function testConfigArrayOjectCanStoreDataDirectly() { $arrayObject = $this->configLoader->getArrayObject('test'); $arrayObject->set('users.0.username', "Exts Developer"); $arrayObject->set('users.0.email', "*****@*****.**"); $arrayObject->set('users.2.username', "Exts Developer Test"); $arrayObject->set('users.2.email', "*****@*****.**"); $this->assertTrue($arrayObject->get('users.0.username') == "Exts Developer"); $this->assertTrue($arrayObject->get('users.0.email') == "*****@*****.**"); $this->assertTrue($arrayObject->get('users.2.username') == "Exts Developer Test"); $this->assertTrue($arrayObject->get('users.2.email') == "*****@*****.**"); $this->assertTrue(count($arrayObject['users']) == 3); }
public function testConfigStorageUsingYAMLStorageInterfaceAndStoredObjectShouldMatchLoadedObject() { $array = ['account' => ['user' => ['username' => 'Lamonte', 'age' => 25], 'posts' => 12345]]; $savePath = __DIR__ . $this->tempFile; $arrayObject = new ConfigArray($array); $yamlStorage = new Storage\YAML(dirname($savePath)); $configStorage = new ConfigStorage($yamlStorage); $configStorage->store(basename($savePath), (array) $arrayObject); $configLoader = new ConfigLoader(new Loader\YAML(dirname($savePath))); $data = $configLoader->getArrayObject(basename($savePath)); $this->assertTrue($data == $arrayObject); $this->assertTrue(file_exists($savePath)); }