コード例 #1
0
 public function testIsNull()
 {
     $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::STRING);
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new QtiString(''));
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new QtiString('String!'));
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER);
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new QtiInteger(0));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new QtiInteger(-1));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new QtiInteger(100));
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::FLOAT);
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new QtiFloat(0.25));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new QtiFloat(-1.2));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new QtiFloat(100.12));
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::BOOLEAN);
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new QtiBoolean(true));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new QtiBoolean(false));
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::MULTIPLE, BaseType::BOOLEAN);
     $this->assertTrue($outcome->isNull());
     $value = $outcome->getValue();
     $value[] = new QtiBoolean(true);
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::ORDERED, BaseType::STRING);
     $this->assertTrue($outcome->isNull());
     $value = $outcome->getValue();
     $value[] = new QtiString('string!');
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::RECORD);
     $this->assertTrue($outcome->isNull());
     $value = $outcome->getValue();
     $value['point1'] = new QtiPoint(100, 200);
     $this->assertFalse($outcome->isNull());
 }