我正在使用Symfony 3和Behat 3以及Oracle数据库。由于某些情况,我有可能直接编写oracle sql代码。
我坚持以下错误
- \ AppBundle \ Features \ Context \ UserSetupContext.php“致命错误:未定义的常量'OCI_COMMIT_ON_SUCCESS' (贝哈特\试验工作\呼叫\异常\ FatalThrowableError)
首先我认为这是因为php.ini中缺少oci扩展名。但它已启用,可以在具有相同项目的控制器/命令环境中使用。
所以我认为数据库连接没有连接,但我找不到问题。请帮忙。
文件:
<?php
-- \AppBundle\Features\Context\UserSetupContext.php
namespace AppBundle\Features\Context;
use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\TableNode;
use Symfony\Component\VarDumper\VarDumper;
class UserSetupContext implements Context
{
/**
* @var \Doctrine\DBAL\Connection
*/
private $db;
public function __construct(\Doctrine\DBAL\Connection $db)
{
$this->db = $db;
}
/**
* @Given there are Users with the following details:
*/
public function thereAreUsersWithTheFollowingDetails(TableNode $users)
{
foreach ($users->getColumnsHash() as $value) {
// Test SQL
$query = "INSERT INTO IT_MONITORING.USERS (
ID
, firstname
, lastname
, username
, password
, email
, status_id)
VALUES (
:id
, :firstname
, :lastname
, :username
, :password
, :email
, 1)";
$query = $this->db->prepare($query);
$query->bindValue("id", $value['id'], \PDO::PARAM_STR);
$query->bindValue("firstname", $value['firstname'], \PDO::PARAM_STR);
$query->bindValue("lastname", $value['lastname'], \PDO::PARAM_STR);
$query->bindValue("username", $value['username'], \PDO::PARAM_STR);
$query->bindValue("password", password_hash($value['password'], PASSWORD_DEFAULT), \PDO::PARAM_STR);
$query->bindValue("email", $value['email'], \PDO::PARAM_STR);
$result = $query->execute();
VarDumper::dump($result);
}
}
}
和Config
--\behat.yml
default:
suites:
default:
type: symfony_bundle
bundle: AppBundle
contexts:
- FeatureContext:
doctrine: "@doctrine"
- AppBundle\Features\Context\UserSetupContext:
db: "@doctrine.dbal.test_connection"
extensions:
Behat\Symfony2Extension:
kernel:
env: "dev"
debug: "true"
Behat\MinkExtension:
base_url: "http://url"
sessions:
defaults:
symfony2: ~