Skip to content

Commit

Permalink
changed to static assert-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tombrain committed Nov 5, 2023
1 parent be09aa2 commit 98ef1a7
Show file tree
Hide file tree
Showing 38 changed files with 753 additions and 753 deletions.
36 changes: 18 additions & 18 deletions tests/uts/dbFormhandler_BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ public function testConstructor(): void
{
$form = new dbFormHandler();

$this->assertInstanceOf("dbFormHandler", $form);
static::assertInstanceOf("dbFormHandler", $form);

$_sql = $this->getPrivateProperty($form, '_sql');
$this->assertTrue(is_array($_sql));
$this->assertEquals(0, sizeof($_sql));
static::assertTrue(is_array($_sql));
static::assertEquals(0, sizeof($_sql));

$_dbData = $this->getPrivateProperty($form, '_dbData');
$this->assertTrue(is_array($_dbData));
$this->assertEquals(0, sizeof($_dbData));
static::assertTrue(is_array($_dbData));
static::assertEquals(0, sizeof($_dbData));

$_dontSave = $this->getPrivateProperty($form, '_dontSave');
$this->assertTrue(is_array($_dontSave));
$this->assertEquals(0, sizeof($_dontSave));
static::assertTrue(is_array($_dontSave));
static::assertEquals(0, sizeof($_dontSave));

$_id = $this->getPrivateProperty($form, '_id');
$this->assertTrue(is_array($_id));
$this->assertEquals(0, sizeof($_id));
static::assertTrue(is_array($_id));
static::assertEquals(0, sizeof($_id));

$dieOnQuery = $this->getPrivateProperty($form, 'dieOnQuery');
$this->assertFalse($dieOnQuery);
static::assertFalse($dieOnQuery);

$_editName = $this->getPrivateProperty($form, '_editName');
$this->assertEquals("id", $_editName);
static::assertEquals("id", $_editName);

$this->assertTrue($form->insert);
$this->assertFalse($form->edit);
$this->assertFalse($form->isPosted());
static::assertTrue($form->insert);
static::assertFalse($form->edit);
static::assertFalse($form->isPosted());
}

public function test_SetConnectionResource(): void
Expand All @@ -44,12 +44,12 @@ public function test_SetConnectionResource(): void
$this->setConnectedTable($form, "test");

$_db = $this->getPrivateProperty($form, '_db');
$this->assertInstanceOf("YadalDibi", $_db);
static::assertInstanceOf("YadalDibi", $_db);

$this->assertTrue($_db->isConnected());
$this->assertTrue($_db->_quoteNumbers);
static::assertTrue($_db->isConnected());
static::assertTrue($_db->_quoteNumbers);

$_table = $this->getPrivateProperty($form, '_table');
$this->assertEquals("test", $_table);
static::assertEquals("test", $_table);
}
};
56 changes: 28 additions & 28 deletions tests/uts/dbFormhandler_PassFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ public function test_new(): void

$form = new dbFormHandler();

$this->assertTrue($form->insert);
$this->assertFalse($form->edit);
$this->assertFalse($form->isPosted());
static::assertTrue($form->insert);
static::assertFalse($form->edit);
static::assertFalse($form->isPosted());

$this->setConnectedTable($form, "test");

$form->passField("Your password", "pass", FH_PASSWORD);
$form->textField("TextNullable", "textNullable");

$this->assertEmpty($form->getValue("textNullable"));
$this->assertEmpty($form->getValue("textNotNullable"));
static::assertEmpty($form->getValue("textNullable"));
static::assertEmpty($form->getValue("textNotNullable"));

$this->assertFormFlushContains($form, [
static::assertFormFlushContains($form, [
'Your password:<input type="password" name="pass" id="pass" size="20" />error_pass',
'TextNullable:<input type="text" name="textNullable" id="textNullable" value="" size="20" />error_textNullable'
]);
Expand All @@ -36,9 +36,9 @@ public function test_edit(): void

$form = new dbFormHandler();

$this->assertFalse($form->insert);
$this->assertTrue($form->edit);
$this->assertFalse($form->isPosted());
static::assertFalse($form->insert);
static::assertTrue($form->edit);
static::assertFalse($form->isPosted());

$this->getDatabaseMock()
->expects($this->exactly(1))
Expand All @@ -52,10 +52,10 @@ public function test_edit(): void
$form->passField("Your password", "pass", FH_PASSWORD);
$form->textField("TextNullable", "textNullable");

$this->assertEquals("text1", $form->getValue("textNullable"));
$this->assertEquals("secret", $form->getValue("pass"));
static::assertEquals("text1", $form->getValue("textNullable"));
static::assertEquals("secret", $form->getValue("pass"));

$this->assertFormFlushContains($form, [
static::assertFormFlushContains($form, [
'Your password:<input type="password" name="pass" id="pass" size="20" />error_pass',
'TextNullable:<input type="text" name="textNullable" id="textNullable" value="text1" size="20" />error_textNullable'
]);
Expand All @@ -67,9 +67,9 @@ public function test_insert_noValues(): void

$form = new dbFormHandler();

$this->assertTrue($form->insert);
$this->assertFalse($form->edit);
$this->assertTrue($form->isPosted());
static::assertTrue($form->insert);
static::assertFalse($form->edit);
static::assertTrue($form->isPosted());

$this->setConnectedTable($form, "test");

Expand All @@ -78,7 +78,7 @@ public function test_insert_noValues(): void
$e = $form->catchErrors();

$expected = "You did not enter a correct value for this field!";
$this->assertStringContainsString($expected, $e['pass']);
static::assertStringContainsString($expected, $e['pass']);
}

public function test_insert(): void
Expand All @@ -91,9 +91,9 @@ public function test_insert(): void

$form = new dbFormHandler();

$this->assertTrue($form->insert);
$this->assertFalse($form->edit);
$this->assertTrue($form->isPosted());
static::assertTrue($form->insert);
static::assertFalse($form->edit);
static::assertTrue($form->isPosted());

$this->setConnectedTable($form, "test");

Expand All @@ -111,7 +111,7 @@ public function test_insert(): void

$r = $form->flush(true);

$this->assertEmpty($r);
static::assertEmpty($r);
$this->assertSavedId(4711);
$this->assertSavedValue('secret', 'pass');
$this->assertSavedValue('thetext', 'textNullable');
Expand All @@ -126,8 +126,8 @@ public function test_insert(): void

// $form = new dbFormHandler();

// $this->assertFalse($form->insert);
// $this->assertTrue($form->edit);
// static::assertFalse($form->insert);
// static::assertTrue($form->edit);

// $this->getDatabaseMock()
// ->expects($this->exactly(1))
Expand All @@ -149,9 +149,9 @@ public function test_insert(): void

// $r = $form->flush(true);

// $this->fail("forced failure: empty pass fails");
// static::fail("forced failure: empty pass fails");

// $this->assertEquals("", $r);
// static::assertEquals("", $r);
// $this->assertSavedId(4714);
// $this->assertSavedValueEmtpy('textNullable');
// }
Expand All @@ -166,9 +166,9 @@ public function test_update(): void

$form = new dbFormHandler();

$this->assertFalse($form->insert);
$this->assertTrue($form->edit);
$this->assertTrue($form->isPosted());
static::assertFalse($form->insert);
static::assertTrue($form->edit);
static::assertTrue($form->isPosted());

$this->getDatabaseMock()
->expects($this->exactly(1))
Expand All @@ -190,7 +190,7 @@ public function test_update(): void

$r = $form->flush(true);

$this->assertEmpty($r);
static::assertEmpty($r);
$this->assertSavedId(4715);
$this->assertSavedValue("newpass", "pass");
}
Expand Down
62 changes: 31 additions & 31 deletions tests/uts/dbFormhandler_TextFieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ public function test_new(): void

$form = new dbFormHandler();

$this->assertTrue($form->insert);
$this->assertFalse($form->edit);
$this->assertFalse($form->isPosted());
static::assertTrue($form->insert);
static::assertFalse($form->edit);
static::assertFalse($form->isPosted());

$this->setConnectedTable($form, "test");

$form->textField("TextNullable", "textNullable");
$form->textField("TextNotNullable", "textNotNullable");

$this->assertEmpty($form->getValue("textNullable"));
$this->assertEmpty($form->getValue("textNotNullable"));
static::assertEmpty($form->getValue("textNullable"));
static::assertEmpty($form->getValue("textNotNullable"));

$this->assertFormFlushContains($form, [
static::assertFormFlushContains($form, [
'input type="text" name="textNullable" id="textNullable" value=""',
'input type="text" name="textNotNullable" id="textNotNullable" value=""'
]);
Expand All @@ -36,9 +36,9 @@ public function test_edit_noDataset(): void

$form = new dbFormHandler();

$this->assertFalse($form->insert);
$this->assertTrue($form->edit);
$this->assertFalse($form->isPosted());
static::assertFalse($form->insert);
static::assertTrue($form->edit);
static::assertFalse($form->isPosted());

$this->getDatabaseMock()
->expects($this->exactly(1))
Expand All @@ -57,9 +57,9 @@ public function test_edit(): void

$form = new dbFormHandler();

$this->assertFalse($form->insert);
$this->assertTrue($form->edit);
$this->assertFalse($form->isPosted());
static::assertFalse($form->insert);
static::assertTrue($form->edit);
static::assertFalse($form->isPosted());

$this->getDatabaseMock()
->expects($this->exactly(1))
Expand All @@ -73,10 +73,10 @@ public function test_edit(): void
$form->textField("TextNullable", "textNullable");
$form->textField("TextNotNullable", "textNotNullable");

$this->assertEquals("text1", $form->getValue("textNullable"));
$this->assertEquals("text2", $form->getValue("textNotNullable"));
static::assertEquals("text1", $form->getValue("textNullable"));
static::assertEquals("text2", $form->getValue("textNotNullable"));

$this->assertFormFlushContains($form, [
static::assertFormFlushContains($form, [
'input type="text" name="textNullable" id="textNullable" value="text1"',
'input type="text" name="textNotNullable" id="textNotNullable" value="text2"'
]);
Expand All @@ -90,9 +90,9 @@ public function test_insert_noValues(): void

$form = new dbFormHandler();

$this->assertTrue($form->insert);
$this->assertFalse($form->edit);
$this->assertTrue($form->isPosted());
static::assertTrue($form->insert);
static::assertFalse($form->edit);
static::assertTrue($form->isPosted());

$this->setConnectedTable($form, "test");

Expand All @@ -109,7 +109,7 @@ public function test_insert_noValues(): void

$r = $form->flush(true);

$this->assertEmpty($r);
static::assertEmpty($r);
$this->assertSavedId(4712);
$this->assertSavedValueEmtpy('textNullable');
$this->assertSavedValueEmtpy('textNotNullable');
Expand All @@ -125,9 +125,9 @@ public function test_insert(): void

$form = new dbFormHandler();

$this->assertTrue($form->insert);
$this->assertFalse($form->edit);
$this->assertTrue($form->isPosted());
static::assertTrue($form->insert);
static::assertFalse($form->edit);
static::assertTrue($form->isPosted());

$this->setConnectedTable($form, "test");

Expand All @@ -144,7 +144,7 @@ public function test_insert(): void

$r = $form->flush(true);

$this->assertEmpty($r);
static::assertEmpty($r);
$this->assertSavedId(4713);
$this->assertSavedValue('thetext', 'textNullable');
$this->assertSavedValue('anothertext', 'textNotNullable');
Expand All @@ -159,9 +159,9 @@ public function test_update_noValues(): void

$form = new dbFormHandler();

$this->assertFalse($form->insert);
$this->assertTrue($form->edit);
$this->assertTrue($form->isPosted());
static::assertFalse($form->insert);
static::assertTrue($form->edit);
static::assertTrue($form->isPosted());

$this->getDatabaseMock()
->expects($this->exactly(1))
Expand All @@ -183,7 +183,7 @@ public function test_update_noValues(): void

$r = $form->flush(true);

$this->assertEmpty($r);
static::assertEmpty($r);
$this->assertSavedId(4714);
$this->assertSavedValueEmtpy('textNullable');
$this->assertSavedValueEmtpy('textNotNullable');
Expand All @@ -200,9 +200,9 @@ public function test_update(): void

$form = new dbFormHandler();

$this->assertFalse($form->insert);
$this->assertTrue($form->edit);
$this->assertTrue($form->isPosted());
static::assertFalse($form->insert);
static::assertTrue($form->edit);
static::assertTrue($form->isPosted());

$this->getDatabaseMock()
->expects($this->exactly(1))
Expand All @@ -223,7 +223,7 @@ public function test_update(): void

$r = $form->flush(true);

$this->assertEmpty($r);
static::assertEmpty($r);
$this->assertSavedId(4715);
$this->assertSavedValue('thetext', 'textNullable');
$this->assertSavedValue('anothertext', 'textNotNullable');
Expand Down
Loading

0 comments on commit 98ef1a7

Please sign in to comment.