Skip to content

Commit

Permalink
Merge branch 'MDL-72329' of https://github.com/stronk7/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols authored and stronk7 committed Oct 1, 2021
2 parents bb0942a + 0df1347 commit 0437f40
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions lib/tests/persistent_test.php
Expand Up @@ -79,10 +79,10 @@ protected function make_second_persistent_table() {

$table = new xmldb_table(core_testable_second_persistent::TABLE);
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('int', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('someint', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('intnull', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
$table->add_field('float', XMLDB_TYPE_FLOAT, '10', null, null, null, null);
$table->add_field('text', XMLDB_TYPE_TEXT, null, null, null, null, null);
$table->add_field('somefloat', XMLDB_TYPE_FLOAT, '10,5', null, null, null, null);
$table->add_field('sometext', XMLDB_TYPE_TEXT, null, null, null, null, null);
$table->add_field('raw', XMLDB_TYPE_CHAR, '100', null, null, null, null);
$table->add_field('booltrue', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
$table->add_field('boolfalse', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
Expand Down Expand Up @@ -475,10 +475,10 @@ public function test_get_sql_fields_too_long() {

public function test_get(): void {
$data = [
'int' => 123,
'someint' => 123,
'intnull' => null,
'float' => 33.44,
'text' => 'Hello',
'somefloat' => 33.44,
'sometext' => 'Hello',
'raw' => '/dev/hello',
'booltrue' => true,
'boolfalse' => false,
Expand All @@ -487,20 +487,20 @@ public function test_get(): void {
$p->create();

$this->assertSame($data['intnull'], $p->get('intnull'));
$this->assertSame($data['int'], $p->get('int'));
$this->assertSame($data['float'], $p->get('float'));
$this->assertSame($data['text'], $p->get('text'));
$this->assertSame($data['someint'], $p->get('someint'));
$this->assertSame($data['somefloat'], $p->get('somefloat'));
$this->assertSame($data['sometext'], $p->get('sometext'));
$this->assertSame($data['raw'], $p->get('raw'));
$this->assertSame($data['booltrue'], $p->get('booltrue'));
$this->assertSame($data['boolfalse'], $p->get('boolfalse'));

// Ensure that types are correct after reloading data from database.
$p->read();

$this->assertSame($data['int'], $p->get('int'));
$this->assertSame($data['someint'], $p->get('someint'));
$this->assertSame($data['intnull'], $p->get('intnull'));
$this->assertSame($data['float'], $p->get('float'));
$this->assertSame($data['text'], $p->get('text'));
$this->assertSame($data['somefloat'], $p->get('somefloat'));
$this->assertSame($data['sometext'], $p->get('sometext'));
$this->assertSame($data['raw'], $p->get('raw'));
$this->assertSame($data['booltrue'], $p->get('booltrue'));
$this->assertSame($data['boolfalse'], $p->get('boolfalse'));
Expand Down Expand Up @@ -627,18 +627,18 @@ class core_testable_second_persistent extends \core\persistent {
*/
protected static function define_properties(): array {
return [
'int' => [
'someint' => [
'type' => PARAM_INT,
],
'intnull' => [
'type' => PARAM_INT,
'null' => NULL_ALLOWED,
'default' => null,
],
'float' => [
'somefloat' => [
'type' => PARAM_FLOAT,
],
'text' => [
'sometext' => [
'type' => PARAM_TEXT,
'default' => ''
],
Expand Down

0 comments on commit 0437f40

Please sign in to comment.