Esempio n. 1
0
 /**
  * @dataProvider getData
  *
  * @param array $data
  *
  * @return void
  */
 public function test_function(array $data)
 {
     // prepare
     $this->setExpectedException($data['exception'], $data['message']);
     MockDataManipulation::initDataContainer(['collection' => ['id' => ['field' => 'value']]]);
     // invoke logic & test
     MockDataManipulation::getInstance()->saveData($data['value'], $data['collection'], $data['id'], $data['field']);
 }
 /**
  * @return void
  */
 public function test_function()
 {
     // prepare
     $this->setExpectedException('\\UnexpectedValueException', 'Collection \'fooBar\' does not exist');
     MockDataManipulation::initDataContainer(['collection' => ['id' => []]]);
     // invoke logic & test
     MockDataManipulation::getInstance()->deleteRow('fooBar', ['id']);
 }
 /**
  * @dataProvider getData
  *
  * @param array $data
  *
  * @return void
  */
 public function test_function(array $data)
 {
     // prepare
     $this->setExpectedException('\\UnexpectedValueException', $data['errorMessage']);
     MockDataManipulation::initDataContainer(['collection' => ['id' => []]]);
     // invoke logic & test
     MockDataManipulation::getInstance()->getCollectionElements($data['collection'], $data['id']);
 }
Esempio n. 4
0
 /**
  * @dataProvider getData
  *
  * @param array $data
  *
  * @return void
  */
 public function test_function(array $data)
 {
     // prepare
     MockDataManipulation::initDataContainer(['collection1' => ['id1' => [1], 'id2' => [2]], 'collection2' => ['id3' => [1], 'id4' => [2]]]);
     // invoke logic
     $result = MockDataManipulation::getInstance()->getAllIds($data['collections'], $data['byCollection']);
     // test
     $this->assertEquals($data['expected'], $result);
 }
 /**
  * @dataProvider getData
  *
  * @param array $data
  *
  * @return void
  */
 public function test_function(array $data)
 {
     // prepare
     MockDataManipulation::initDataContainer(['collection' => ['id' => [1]]]);
     // invoke logic
     $result = MockDataManipulation::getInstance()->getCollectionElements($data['collection'], $data['id']);
     // test
     $this->assertEquals($data['expected'], $result);
 }
 /**
  * @dataProvider getData
  *
  * @param array $data
  *
  * @return void
  */
 public function test_function(array $data)
 {
     // prepare
     MockDataManipulation::initDataContainer(['collection1' => ['id1' => [1], 'id2' => [2]], 'collection2' => ['id3' => [1], 'id4' => [2]]]);
     $reflection = new \ReflectionClass('\\DbMockLibrary\\MockDataManipulation');
     $dataProperty = $reflection->getProperty('data');
     $dataProperty->setAccessible(true);
     // invoke logic
     MockDataManipulation::getInstance()->dropCollections($data['collections']);
     // test
     $this->assertEquals($data['expected'], $dataProperty->getValue(MockDataManipulation::getInstance()));
 }
 /**
  * @dataProvider getData
  *
  * @param array $data
  *
  * @return void
  */
 public function test_function(array $data)
 {
     // prepare
     MockDataManipulation::initDataContainer(['collection1' => [], 'collection2' => []]);
     $reflection = new \ReflectionClass('\\DbMockLibrary\\MockDataManipulation');
     $getAllCollectionsIfEmptyMethod = $reflection->getMethod('getAllCollectionsIfEmpty');
     $getAllCollectionsIfEmptyMethod->setAccessible(true);
     // invoke logic
     $result = $getAllCollectionsIfEmptyMethod->invoke(MockDataManipulation::getInstance(), $data['collections']);
     // test
     $this->assertEquals($data['expected'], $result);
 }
Esempio n. 8
0
 /**
  * @dataProvider getData
  *
  * @param array $data
  *
  * @return void
  */
 public function test_function(array $data)
 {
     // prepare
     MockDataManipulation::initDataContainer(['collection' => ['id' => ['field' => 'value']]]);
     $reflection = new \ReflectionClass('\\DbMockLibrary\\MockDataManipulation');
     $dataProperty = $reflection->getProperty('data');
     $dataProperty->setAccessible(true);
     // invoke logic
     MockDataManipulation::getInstance()->saveData($data['value'], $data['collection'], $data['id'], $data['field'], $data['strict']);
     // test
     $this->assertEquals($data['expected'], $dataProperty->getValue(MockDataManipulation::getInstance()));
 }
Esempio n. 9
0
 /**
  * @return void
  */
 public function test_function()
 {
     // invoke logic
     $dataArray = ['collection' => ['id1' => [1], 'id2' => [2]]];
     MockDataManipulation::initDataContainer($dataArray);
     $reflection = new \ReflectionClass('\\DbMockLibrary\\MockDataManipulation');
     $dataProperty = $reflection->getProperty('data');
     $dataProperty->setAccessible(true);
     // invoke logic
     MockDataManipulation::getInstance()->deleteRow('collection', ['id1', 'id2']);
     // test
     $this->assertEquals(['collection' => []], $dataProperty->getValue(MockDataManipulation::getInstance()));
 }