Commit 3bd81392 authored by Volker Krause's avatar Volker Krause
Browse files

Add unit test for empty sample inserts

parent 6417cd4b
......@@ -44,7 +44,6 @@ class SurveyTest extends AbstractDatastoreTest
Sample::insert(self::$db, $sample, $p);
$dataJson = Sample::dataAsJson(self::$db, $p);
echo ("\n $dataJson \n");
$data = json_decode($dataJson);
$this->assertTrue(is_array($data));
$this->assertCount(2, $data);
......@@ -77,7 +76,6 @@ class SurveyTest extends AbstractDatastoreTest
Sample::insert(self::$db, $sample, $p);
$dataJson = Sample::dataAsJson(self::$db, $p);
echo ("\n $dataJson \n");
$data = json_decode($dataJson);
$this->assertTrue(is_array($data));
$this->assertCount(1, $data);
......@@ -90,6 +88,29 @@ class SurveyTest extends AbstractDatastoreTest
$this->assertObjectHasAttribute('key2', $d01);
}
public function testEmptyInsert()
{
$p = Product::productByName(self::$db, 'org.kde.UnitTest');
$this->assertNotNull($p);
$p->name = 'org.kde.MyEmptyProduct';
$p->insert(self::$db);
$sample = '{
"someRandomStuff": "not part of the schema",
"someOtherStuff": 42
}';
Sample::insert(self::$db, $sample, $p);
$dataJson = Sample::dataAsJson(self::$db, $p);
$data = json_decode($dataJson);
$this->assertTrue(is_array($data));
$this->assertCount(1, $data);
$d0 = $data[0];
$this->assertObjectHasAttribute('timestamp', $d0);
$this->assertObjectNotHasAttribute('entry1', $d0);
$this->assertObjectNotHasAttribute('someRandomStuff', $d0);
}
public function testInvalidInsert_data()
{
return [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment