Skip to content

Commit

Permalink
🔨 #89 create menu SP
Browse files Browse the repository at this point in the history
  • Loading branch information
bjverde committed Jun 21, 2019
1 parent b85dda2 commit 1197edc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
6 changes: 6 additions & 0 deletions classes/TCreateMenu.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public function addBasicMenuViews()
$this->addBasicMenuItems( '2', TableInfo::TB_TYPE_VIEW );
}
//--------------------------------------------------------------------------------------
public function addBasicMenuProcedure()
{
$this->addLine('$menu->add(\'3\', null, \'Procedure\', null, null, \'menu-alt-512.png\');');
$this->addBasicMenuItems( '3', TableInfo::TB_TYPE_PROCEDURE );
}
//--------------------------------------------------------------------------------------
public function show($print = false)
{
$this->lines=null;
Expand Down
13 changes: 12 additions & 1 deletion tests/TCreateMenuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function tearDown()

public function testAddBasicMenuCruds_3tables()
{
$expected = 4; //4 Tables + 1 header line
$expected = 4; //3 Tables + 1 header line
$listTableNames = $this->mockDatabase->generateTablesSelected3t5v();
$this->createMenu->setListTableNames($listTableNames);
$this->createMenu->addBasicMenuCruds();
Expand Down Expand Up @@ -104,4 +104,15 @@ public function testAddBasicMenuViews_7Views()
$size = CountHelper::count($resultArray);
$this->assertEquals($expected, $size);
}

public function testAddBasicMenuViews_2StoredProcedure()
{
$expected = 3; //2 SP + 1 header line
$listTableNames = $this->mockDatabase->generateTablesSelected3t5v2p();
$this->createMenu->setListTableNames($listTableNames);
$this->createMenu->addBasicMenuProcedure();
$resultArray = $this->createMenu->getLinesArray();
$size = CountHelper::count($resultArray);
$this->assertEquals($expected, $size);
}
}
16 changes: 16 additions & 0 deletions tests/mockDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ public function generateTablesSelected1t7v()
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'v5' ,null, TableInfo::TB_TYPE_VIEW);
return $tableSelected;
}

public function generateTablesSelected3t5v2p()
{
$tableSelected = array();
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'menu' ,null, TableInfo::TB_TYPE_TABLE);
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'acess',null, TableInfo::TB_TYPE_TABLE);
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'vitem',null, TableInfo::TB_TYPE_VIEW);
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'list' ,null, TableInfo::TB_TYPE_TABLE);
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'v2' ,null, TableInfo::TB_TYPE_VIEW);
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'v3' ,null, TableInfo::TB_TYPE_VIEW);
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'v4' ,null, TableInfo::TB_TYPE_VIEW);
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'v5' ,null, TableInfo::TB_TYPE_VIEW);
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'sp1' ,null, TableInfo::TB_TYPE_PROCEDURE);
$tableSelected = $this->includeTable($tableSelected, 'dbo', 'sp2' ,null, TableInfo::TB_TYPE_PROCEDURE);
return $tableSelected;
}

/***
* Add a new row in the table that represents the list of fields and their
Expand Down

0 comments on commit 1197edc

Please sign in to comment.