Skip to content

Commit

Permalink
Correct namespaces in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeckerson committed Mar 14, 2021
1 parent b85e752 commit 56c27d9
Show file tree
Hide file tree
Showing 12 changed files with 136 additions and 85 deletions.
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@
},
"autoload-dev": {
"psr-4": {
"Phalcon\\Test\\": "tests/unit",
"Phalcon\\Test\\Models\\": "tests/_data/models",
"Phalcon\\Test\\Module\\": "tests/_support/Module"
"Phalcon\\DevTools\\Tests\\Acceptance\\": "tests/acceptance/",
"Phalcon\\DevTools\\Tests\\Console\\": "tests/console/",
"Phalcon\\DevTools\\Tests\\Functional\\": "tests/functional/",
"Phalcon\\DevTools\\Tests\\Unit\\": "tests/unit/",
"Phalcon\\DevTools\\Tests\\Support\\Module\\": "tests/_support/Module"
},
"files": [
"tests/_support/helpers.php"
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/_support/Module/UnitTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Phalcon\Test\Module;
namespace Phalcon\DevTools\Tests\Support\Module;

use Codeception\Specify;
use Codeception\Test\Unit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

use AcceptanceTester;
use Codeception\Util\Fixtures;
use Codeception\Util\Locator;

final class ScaffoldPhtmlCest
{
/**
* @group mysql
* @param AcceptanceTester $I
*/
public function before(AcceptanceTester $I): void
{
Expand Down Expand Up @@ -40,21 +40,22 @@ public function before(AcceptanceTester $I): void

$content = file_get_contents($loaderFile);

//Add namespace
// Add namespace
$returnLine = "\r\n";

$content .= $returnLine .
'$loader->registerNamespaces(' .
$returnLine . '[ '.
'"'.$namespace.'" => $config->application->modelsDir' .
$returnLine . ' ]' .
$returnLine . '[ ' .
'"' . $namespace . '" => $config->application->modelsDir' .
$returnLine . ' ]' .
$returnLine . ');';

file_put_contents($loaderFile, $content);
}

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testGenScaffoldFileExist(AcceptanceTester $I): void
{
Expand Down Expand Up @@ -115,12 +116,13 @@ public function testGenScaffoldFileExist(AcceptanceTester $I): void

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testSearchAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename'));
$I->amOnPage('/' . Fixtures::get('tablename'));
$I->see(Fixtures::get('tablename'));
$I->see('Search '.Fixtures::get('tablename'));
$I->see('Search ' . Fixtures::get('tablename'));
$I->see('Dateofbirth');
$I->fillField('dateofbirth', '2019-04-17');
$I->click('input[type=submit]');
Expand All @@ -130,37 +132,34 @@ public function testSearchAction(AcceptanceTester $I): void

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testSearchButtonAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename').'/search');
$I->amOnPage('/' . Fixtures::get('tablename') . '/search');
$I->see('Search result');

$I->click("#next");

$I->see("K1S6X");

$I->click("#previous");

$I->see("U7B0Q");

$I->click("#last");

$I->see("N2Z7T");

$I->click("#first");

$I->see("U7B0Q");
}


/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testNewAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename').'/new');
$I->see('Create '.Fixtures::get('tablename'));
$I->amOnPage('/' . Fixtures::get('tablename') . '/new');
$I->see('Create ' . Fixtures::get('tablename'));
$I->fillField('firstname', 'jeremy');
$I->fillField('surname', 'jenovateurs');
$I->fillField('membertype', 'aaa');
Expand All @@ -170,47 +169,35 @@ public function testNewAction(AcceptanceTester $I): void

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testEditAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename').
'/search');
$I->amOnPage('/' . Fixtures::get('tablename') . '/search');
$I->see('Search result');
$I->click(['link' => 'Edit']);
$I->seeInField('firstname', 'Hedley');
$I->fillField('firstname', 'samedi');
$I->click('input[type=submit]');
$I->amOnPage('/'.Fixtures::get('tablename').
$I->amOnPage('/' . Fixtures::get('tablename') .
'/search');
$I->see('Search result');
//Check if edit work
// $I->see('samedi');
// $I->see('samedi');
}

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testDeleteAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename').
'/search');
$I->amOnPage('/' . Fixtures::get('tablename') . '/search');
$I->see('Search result');
$I->click(['link' => 'Delete']);
$I->see('customer was deleted successfully');

$I->amOnPage('/'.Fixtures::get('tablename').
'/search');
$I->amOnPage('/' . Fixtures::get('tablename') . '/search');
$I->cantSee('Hedley');
}

/**
* @group mysql
*/
public function after(AcceptanceTester $I): void
{
/*$I->deleteFile(Fixtures::get('controller'));
$I->deleteFile(Fixtures::get('model'));
$I->deleteFile(Fixtures::get('layout'));
$I->deleteDir(Fixtures::get('views'));*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

use AcceptanceTester;
use Codeception\Util\Fixtures;
use Codeception\Util\Locator;

final class ScaffoldVoltCest
{
/**
* @group mysql
* @param AcceptanceTester $I
*/
public function before(AcceptanceTester $I): void
{
Expand Down Expand Up @@ -45,16 +45,17 @@ public function before(AcceptanceTester $I): void

$content .= $returnLine .
'$loader->registerNamespaces(' .
$returnLine . '[ '.
'"'.$namespace.'" => $config->application->modelsDir' .
$returnLine . ' ]' .
$returnLine . '[ ' .
'"' . $namespace . '" => $config->application->modelsDir' .
$returnLine . ' ]' .
$returnLine . ');';

file_put_contents($loaderFile, $content);
}

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testGenScaffoldFileExist(AcceptanceTester $I): void
{
Expand Down Expand Up @@ -115,12 +116,13 @@ public function testGenScaffoldFileExist(AcceptanceTester $I): void

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testSearchAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename'));
$I->amOnPage('/' . Fixtures::get('tablename'));
$I->see(Fixtures::get('tablename'));
$I->see('Search '.Fixtures::get('tablename'));
$I->see('Search ' . Fixtures::get('tablename'));
$I->see('Dateofbirth');
$I->fillField('dateofbirth', '2019-04-17');
$I->click('input[type=submit]');
Expand All @@ -130,37 +132,34 @@ public function testSearchAction(AcceptanceTester $I): void

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testSearchButtonAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename').'/search');
$I->amOnPage('/' . Fixtures::get('tablename') . '/search');
$I->see('Search result');

$I->click("#next");

$I->see("K1S6X");

$I->click("#previous");

$I->see("W2Q7K");

$I->click("#last");

$I->see("N2Z7T");

$I->click("#first");

$I->see("W2Q7K");
}


/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testNewAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename').'/new');
$I->see('Create '.Fixtures::get('tablename'));
$I->amOnPage('/' . Fixtures::get('tablename') . '/new');
$I->see('Create ' . Fixtures::get('tablename'));
$I->fillField('firstname', 'jeremy');
$I->fillField('surname', 'jenovateurs');
$I->fillField('membertype', 'aaa');
Expand All @@ -170,41 +169,41 @@ public function testNewAction(AcceptanceTester $I): void

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testEditAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename').
$I->amOnPage('/' . Fixtures::get('tablename') .
'/search');
$I->see('Search result');
$I->click(['link' => 'Edit']);
$I->seeInField('firstname', 'Lillian');
$I->fillField('firstname', 'samedi');
$I->click('input[type=submit]');
$I->amOnPage('/'.Fixtures::get('tablename').
'/search');
$I->amOnPage('/' . Fixtures::get('tablename') . '/search');
$I->see('Search result');
//Check if edit work
// $I->see('samedi');
// $I->see('samedi');
}

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function testDeleteAction(AcceptanceTester $I): void
{
$I->amOnPage('/'.Fixtures::get('tablename').
'/search');
$I->amOnPage('/' . Fixtures::get('tablename') . '/search');
$I->see('Search result');
$I->click(['link' => 'Delete']);
$I->see('customer was deleted successfully');

$I->amOnPage('/'.Fixtures::get('tablename').
'/search');
$I->amOnPage('/' . Fixtures::get('tablename') . '/search');
$I->cantSee('samedi');
}

/**
* @group mysql
* @param AcceptanceTester $I
*/
public function after(AcceptanceTester $I): void
{
Expand Down
18 changes: 17 additions & 1 deletion tests/console/GenerateMultyModelsCept.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
<?php

/**
* @var Codeception\Scenario $scenario
* This file is part of the Phalcon Developer Tools.
*
* (c) Phalcon Team <[email protected]>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Phalcon\DevTools\Tests\Console;

use Codeception\Scenario;
use ConsoleTester;

/**
* @var Scenario $scenario
*/

$I = new ConsoleTester($scenario);
Expand Down
Loading

0 comments on commit 56c27d9

Please sign in to comment.