Skip to content

Commit

Permalink
Cleaned up RecordsTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyklay committed May 4, 2020
1 parent 0d02f21 commit 8c75361
Showing 1 changed file with 17 additions and 39 deletions.
56 changes: 17 additions & 39 deletions tests/_data/fixtures/Traits/RecordsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,17 @@
*
* (c) Phalcon Team <team@phalcon.io>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
* For the full copyright and license information, please view the
* LICENSE.txt file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Phalcon\Test\Fixtures\Traits;

use DatabaseTester;
use PDO;
use Phalcon\Annotations\Adapter\Memory as AnnotationsMemory;
use Phalcon\Cache\Adapter\Libmemcached as StorageLibmemcached;
use Phalcon\Cache\Adapter\Stream as StorageStream;
use Phalcon\Cli\Console as CliConsole;
use Phalcon\Crypt;
use Phalcon\Db\Adapter\PdoFactory;
use Phalcon\Di;
use Phalcon\Di\DiInterface;
use Phalcon\Di\FactoryDefault;
use Phalcon\Di\FactoryDefault\Cli as CliFactoryDefault;
use Phalcon\Escaper;
use Phalcon\Events\Manager as EventsManager;
use Phalcon\Filter;
use Phalcon\Http\Request;
use Phalcon\Http\Response;
use Phalcon\Mvc\Model\Manager as ModelsManager;
use Phalcon\Mvc\Model\Metadata\Memory as MetadataMemory;
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Simple;
use Phalcon\Session\Adapter\Libmemcached as SessionLibmemcached;
use Phalcon\Session\Adapter\Noop as SessionNoop;
use Phalcon\Session\Adapter\Redis as SessionRedis;
use Phalcon\Session\Adapter\Stream as SessionFiles;
use Phalcon\Session\Manager as SessionManager;
use Phalcon\Storage\SerializerFactory;
use Phalcon\Test\Fixtures\Migrations\InvoicesMigration;
use Phalcon\Url;
use function dataDir;
use function getOptionsLibmemcached;
use function getOptionsMysql;
use function getOptionsPostgresql;
use function getOptionsRedis;
use function getOptionsSqlite;
use PHPUnit\Framework\Assert;

use function uniqid;

trait RecordsTrait
Expand All @@ -59,7 +27,7 @@ trait RecordsTrait
*/
private function getFibonacci(int $number)
{
return round(pow((sqrt(5) + 1) / 2, $number) / sqrt(5));
return round((((sqrt(5) + 1) / 2) ** $number) / sqrt(5));
}

/**
Expand All @@ -78,15 +46,25 @@ private function insertDataInvoices(
string $prefix,
int $pad = 0
) {
$title = uniqid($prefix . '-');
$title = uniqid($prefix . '-', true);
for ($counter = 1; $counter <= $count; $counter++) {
$migration->insert(
$result = $migration->insert(
$invId,
$custId,
1,
$title,
$this->getFibonacci($pad + $counter)
);

if (!$result) {
$table = $migration->getTable();
$driver = $migration->getDriverName();
Assert::fail(
sprintf("Failed to insert row #%d into table '%s' using '%s' driver", $counter, $table, $driver)
);
}


}
}
}

0 comments on commit 8c75361

Please sign in to comment.