Skip to content

Commit

Permalink
fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed May 17, 2022
1 parent 509bbea commit e8dd9cf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions tests/Backend/Api/Cronjob/CollectionTest.php
Expand Up @@ -69,7 +69,7 @@ public function testGet()
"itemsPerPage": 16,
"entry": [
{
"id": 5,
"id": 4,
"status": 1,
"name": "Test-Cron",
"cron": "* * * * *",
Expand Down Expand Up @@ -99,7 +99,7 @@ public function testGetSearch()
"itemsPerPage": 16,
"entry": [
{
"id": 5,
"id": 4,
"status": 1,
"name": "Test-Cron",
"cron": "* * * * *",
Expand Down Expand Up @@ -129,7 +129,7 @@ public function testGetCount()
"itemsPerPage": 80,
"entry": [
{
"id": 5,
"id": 4,
"status": 1,
"name": "Test-Cron",
"cron": "* * * * *",
Expand Down Expand Up @@ -177,7 +177,7 @@ public function testPost()

$row = Environment::getService('connection')->fetchAssoc($sql);

$this->assertEquals(6, $row['id']);
$this->assertEquals(5, $row['id']);
$this->assertEquals('New-Cron', $row['name']);
$this->assertEquals('5 * * * *', $row['cron']);
$this->assertEquals('Sql-Table', $row['action']);
Expand Down
22 changes: 11 additions & 11 deletions tests/Backend/Api/Cronjob/EntityTest.php
Expand Up @@ -44,7 +44,7 @@ public function getDataSet()

public function testDocumentation()
{
$response = $this->sendRequest('/system/doc/*/backend/cronjob/5', 'GET', array(
$response = $this->sendRequest('/system/doc/*/backend/cronjob/4', 'GET', array(
'User-Agent' => 'Fusio TestCase',
'Authorization' => 'Bearer da250526d583edabca8ac2f99e37ee39aa02a3c076c0edc6929095e20ca18dcf'
));
Expand All @@ -57,15 +57,15 @@ public function testDocumentation()

public function testGet()
{
$response = $this->sendRequest('/backend/cronjob/5', 'GET', array(
$response = $this->sendRequest('/backend/cronjob/4', 'GET', array(
'User-Agent' => 'Fusio TestCase',
'Authorization' => 'Bearer da250526d583edabca8ac2f99e37ee39aa02a3c076c0edc6929095e20ca18dcf'
));

$body = (string) $response->getBody();
$expect = <<<JSON
{
"id": 5,
"id": 4,
"status": 1,
"name": "Test-Cron",
"cron": "* * * * *",
Expand Down Expand Up @@ -97,7 +97,7 @@ public function testGetByName()
$body = (string) $response->getBody();
$expect = <<<JSON
{
"id": 5,
"id": 4,
"status": 1,
"name": "Test-Cron",
"cron": "* * * * *",
Expand Down Expand Up @@ -143,7 +143,7 @@ public function testGetNotFound()

public function testPost()
{
$response = $this->sendRequest('/backend/cronjob/5', 'POST', array(
$response = $this->sendRequest('/backend/cronjob/4', 'POST', array(
'User-Agent' => 'Fusio TestCase',
'Authorization' => 'Bearer da250526d583edabca8ac2f99e37ee39aa02a3c076c0edc6929095e20ca18dcf'
), json_encode([
Expand All @@ -157,7 +157,7 @@ public function testPost()

public function testPut()
{
$response = $this->sendRequest('/backend/cronjob/5', 'PUT', array(
$response = $this->sendRequest('/backend/cronjob/4', 'PUT', array(
'User-Agent' => 'Fusio TestCase',
'Authorization' => 'Bearer da250526d583edabca8ac2f99e37ee39aa02a3c076c0edc6929095e20ca18dcf'
), json_encode([
Expand All @@ -184,17 +184,17 @@ public function testPut()
->where('id = :id')
->getSQL();

$row = Environment::getService('connection')->fetchAssoc($sql, ['id' => 5]);
$row = Environment::getService('connection')->fetchAssoc($sql, ['id' => 4]);

$this->assertEquals(5, $row['id']);
$this->assertEquals(4, $row['id']);
$this->assertEquals('Foo-Cron', $row['name']);
$this->assertEquals('10 * * * *', $row['cron']);
$this->assertEquals('Inspect', $row['action']);
}

public function testDelete()
{
$response = $this->sendRequest('/backend/cronjob/5', 'DELETE', array(
$response = $this->sendRequest('/backend/cronjob/4', 'DELETE', array(
'User-Agent' => 'Fusio TestCase',
'Authorization' => 'Bearer da250526d583edabca8ac2f99e37ee39aa02a3c076c0edc6929095e20ca18dcf'
));
Expand All @@ -214,12 +214,12 @@ public function testDelete()
$sql = Environment::getService('connection')->createQueryBuilder()
->select('id', 'status')
->from('fusio_cronjob')
->where('id = 5')
->where('id = 4')
->getSQL();

$row = Environment::getService('connection')->fetchAssoc($sql);

$this->assertEquals(5, $row['id']);
$this->assertEquals(4, $row['id']);
$this->assertEquals(Table\Cronjob::STATUS_DELETED, $row['status']);
}
}
2 changes: 1 addition & 1 deletion tests/Console/System/CronjobExecuteCommandTest.php
Expand Up @@ -55,7 +55,7 @@ public function testCommand()

$cronjob = $this->connection->fetchAssoc('SELECT * FROM fusio_cronjob WHERE name = :name', ['name' => 'Test-Cron']);

$this->assertEquals(5, $cronjob['id']);
$this->assertEquals(4, $cronjob['id']);
$this->assertEquals(1, $cronjob['status']);
$this->assertEquals('Test-Cron', $cronjob['name']);
$this->assertEquals('* * * * *', $cronjob['cron']);
Expand Down

0 comments on commit e8dd9cf

Please sign in to comment.