Skip to content

Commit

Permalink
Merge branch 'release-19.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
oat-github-bot committed Jan 20, 2025
2 parents 2336405 + 91d9b23 commit 4d3bf75
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 20 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/continuous-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ on:
pull_request:
branches: [ develop ]

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
build:

runs-on: ${{ matrix.operating-system }}
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '7.4', '8.0', '8.1', '8.2', '8.3']
php-version: [ '7.4', '8.0', '8.1', '8.2', '8.3' ]
coverage: [ false ]
include:
- php-version: '8.4'
coverage: true

steps:
- uses: actions/checkout@v3
Expand All @@ -26,7 +33,7 @@ jobs:
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
php-version: ${{ matrix.php-version }}

- name: Validate composer.json and composer.lock
run: composer validate --strict
Expand All @@ -35,7 +42,13 @@ jobs:
run: composer install --prefer-dist --no-progress

- name: Run test suite
if: ${{ !matrix.coverage }}
run: vendor/bin/phpunit

- name: Run test suite with code coverage
if: ${{ matrix.coverage }}
run: php -dxdebug.mode=coverage vendor/bin/phpunit --coverage-clover coverage.xml

- name: Push coverage report
if: ${{ matrix.coverage }}
uses: codecov/codecov-action@v2
11 changes: 8 additions & 3 deletions src/qtism/runtime/expressions/operators/FieldValueProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
namespace qtism\runtime\expressions\operators;

use qtism\data\expressions\operators\FieldValue;
use qtism\runtime\common\RecordContainer;

/**
* The FieldValueProcessor class aims at processing FieldValue expressions.
Expand All @@ -45,16 +46,20 @@ class FieldValueProcessor extends OperatorProcessor
#[\ReturnTypeWillChange]
public function process()
{
$operands = $this->getOperands();
$operand = $this->getOperands()[0];

if ($operands->exclusivelyRecord() === false) {
if ($operand === null) {
return null;
}

if (!$operand instanceof RecordContainer) {
$msg = 'The FieldValue operator only accepts operands with a cardinality of record.';
throw new OperatorProcessingException($msg, $this, OperatorProcessingException::WRONG_CARDINALITY);
}

$fieldIdentifier = $this->getExpression()->getFieldIdentifier();

return $operands[0][$fieldIdentifier];
return $operand[$fieldIdentifier];
}

/**
Expand Down
10 changes: 5 additions & 5 deletions test/qtismtest/common/dom/SerializableDomDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,19 @@ public function testCallingNotExistedVirtualMethods(): void
$dom->$method();
}

public function testCheckThatUnsetIsWorkingSimilarToRealDomObject(): void
public function testMagicMutatorsAndAccessors(): void
{
$serializableDOM = $this->getSerializableDomDocument();
$coreDom = new DOMDocument($serializableDOM->xmlVersion, $serializableDOM->encoding);

$this->assertEquals($coreDom->xmlVersion, $serializableDOM->version);
$this->assertEquals($coreDom->encoding, $serializableDOM->encoding);

unset($coreDom->xmlVersion);
unset($coreDom->encoding);
$coreDom->xmlVersion = null;
$coreDom->encoding = 'ASCII';

unset($serializableDOM->xmlVersion);
unset($serializableDOM->encoding);
$serializableDOM->xmlVersion = null;
$serializableDOM->encoding = 'ASCII';

$this->assertEquals($coreDom->xmlVersion, $serializableDOM->version);
$this->assertEquals($coreDom->encoding, $serializableDOM->encoding);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use qtism\common\datatypes\QtiInteger;
use qtism\common\datatypes\QtiPoint;
use qtism\common\enums\BaseType;
use qtism\data\expressions\Expression;
use qtism\data\QtiComponent;
use qtism\data\storage\xml\marshalling\MarshallerNotFoundException;
use qtism\runtime\common\MultipleContainer;
Expand All @@ -24,7 +25,7 @@ public function testNotEnoughOperands(): void
$expression = $this->createFakeExpression();
$operands = new OperandsCollection();
$this->expectException(ExpressionProcessingException::class);
$processor = new FieldValueProcessor($expression, $operands);
new FieldValueProcessor($expression, $operands);
}

public function testTooMuchOperands(): void
Expand All @@ -34,7 +35,7 @@ public function testTooMuchOperands(): void
$operands[] = new RecordContainer();
$operands[] = new RecordContainer();
$this->expectException(ExpressionProcessingException::class);
$processor = new FieldValueProcessor($expression, $operands);
new FieldValueProcessor($expression, $operands);
}

public function testNullOne(): void
Expand All @@ -55,9 +56,9 @@ public function testNullTwo(): void
$operands = new OperandsCollection();
// null value as operand.
$operands[] = null;
$this->expectException(ExpressionProcessingException::class);
$processor = new FieldValueProcessor($expression, $operands);
$result = $processor->process();
$this::assertNull($result);
}

public function testWrongCardinalityOne(): void
Expand All @@ -68,7 +69,7 @@ public function testWrongCardinalityOne(): void
$operands[] = new QtiInteger(10);
$processor = new FieldValueProcessor($expression, $operands);
$this->expectException(ExpressionProcessingException::class);
$result = $processor->process();
$processor->process();
}

public function testWrongCardinalityTwo(): void
Expand All @@ -79,7 +80,7 @@ public function testWrongCardinalityTwo(): void
$operands[] = new QtiPoint(1, 2);
$processor = new FieldValueProcessor($expression, $operands);
$this->expectException(ExpressionProcessingException::class);
$result = $processor->process();
$processor->process();
}

public function testWrongCardinalityThree(): void
Expand All @@ -91,7 +92,7 @@ public function testWrongCardinalityThree(): void
// Wrong container (Multiple, Ordered)
$processor = new FieldValueProcessor($expression, $operands);
$this->expectException(ExpressionProcessingException::class);
$result = $processor->process();
$processor->process();
}

public function testFieldValue(): void
Expand All @@ -116,7 +117,7 @@ public function testFieldValue(): void
* @return QtiComponent
* @throws MarshallerNotFoundException
*/
public function createFakeExpression($identifier = ''): QtiComponent
public function createFakeExpression($identifier = ''): Expression
{
// The following XML Component creation
// underlines the need of a <record> operator... :)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public function testResponseProcessingErrorCollection(): void

self::assertNotNull($exceptions);
self::assertEquals(
'The FieldValue operator only accepts operands with a cardinality of record.',
'No variable with identifier \'SCORE\' to be set in the current state.',
$exceptions->getProcessingExceptions()[0]->getMessage()
);
}
Expand Down

0 comments on commit 4d3bf75

Please sign in to comment.