Example #1
0
 public function testClone()
 {
     $var = new OutcomeVariable('var', Cardinality::SINGLE, BaseType::INTEGER, new QtiInteger(25));
     $var->setDefaultValue(new QtiInteger(1));
     // value and default value must be independant.
     $clone = clone $var;
     $this->assertNotSame($var->getValue(), $clone->getValue());
     $this->assertNotSame($var->getDefaultValue(), $clone->getDefaultValue());
 }
 public function testIsNull()
 {
     $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::STRING);
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new String(''));
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new String('String!'));
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::INTEGER);
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new Integer(0));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new Integer(-1));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new Integer(100));
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::FLOAT);
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new Float(0.25));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new Float(-1.2));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new Float(100.12));
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::SINGLE, BaseType::BOOLEAN);
     $this->assertTrue($outcome->isNull());
     $outcome->setValue(new Boolean(true));
     $this->assertFalse($outcome->isNull());
     $outcome->setValue(new Boolean(false));
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::MULTIPLE, BaseType::BOOLEAN);
     $this->assertTrue($outcome->isNull());
     $value = $outcome->getValue();
     $value[] = new Boolean(true);
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::ORDERED, BaseType::STRING);
     $this->assertTrue($outcome->isNull());
     $value = $outcome->getValue();
     $value[] = new String('string!');
     $this->assertFalse($outcome->isNull());
     $outcome = new OutcomeVariable('var1', Cardinality::RECORD);
     $this->assertTrue($outcome->isNull());
     $value = $outcome->getValue();
     $value['point1'] = new Point(100, 200);
     $this->assertFalse($outcome->isNull());
 }