* @package taoTests */ class TestPackTest extends TestCase { /** * Test creating an TestPack */ public function testConstructor() { $type = 'qti'; $data = ['foo' => 'bar']; $items = []; $pack = new TestPack($type, $data, $items); $this->assertInstanceOf(TestPack::class, $pack); $this->assertEquals($type, $pack->getType()); $this->assertEquals($data, $pack->getData()); $this->assertEquals($items, $pack->getItems()); } /** * Test the constructor with an empty type */ public function testWrongTypeConstructor() { $this->expectException(InvalidArgumentException::class); new TestPack(null, [], []); } /** * Test the constructor with invalid data */ public function testWrongDataConstructor() { $this->expectException(InvalidArgumentException::class); new TestPack('qti', '{"foo":"bar"}', []); } /** * Test the constructor with invalid data */ public function testWrongItemsConstructor() { $this->expectException(InvalidArgumentException::class); new TestPack('qti', [], 'foo'); } /** * Provides data to test the bundle * @return array() the data */ public function jsonSerializableProvider() { $data = []; return $data; } /** * Test the testPack serializaion */ public function testSerialization() { $testPack = new TestPack('qti', ['foo' => 'bar'], ['foo', 'bar']); $expected = '{"type":"qti","data":{"foo":"bar"},"items":["foo","bar"]}'; $this->assertInstanceOf(TestPack::class, $testPack); $this->assertTrue(is_string($expected)); $this->assertEquals($expected, json_encode($testPack)); } }