Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codeception: oci does not support enabling/disabling integrity check. #16116

Closed
jonny7 opened this issue Apr 17, 2018 · 24 comments
Closed

Codeception: oci does not support enabling/disabling integrity check. #16116

jonny7 opened this issue Apr 17, 2018 · 24 comments

Comments

@jonny7
Copy link
Contributor

jonny7 commented Apr 17, 2018

I am working through the fixture section in the guide, but I am getting the following error, so I think that there should be some more information around this in the docs and examples of work around.

What steps will reproduce the problem?

Using an Oracle DB

Follow the guide https://www.yiiframework.com/doc/guide/2.0/en/test-fixtures to $profile = $I->grabFixture('profiles', 'user1');

What is the expected result?

That the fixture is loaded and I can see the record in DB.

What do you get instead?

Exception in Console when running tests

[yii\base\NotSupportedException] oci does not support enabling/disabling integrity check.

Additional info

Q A
Yii version 2.0.15.1
PHP version 7.1.1
Operating system Windows 7
@jonny7 jonny7 changed the title Add documentation around Errors for Oracle specific fixtures Codeception: [yii\base\NotSupportedException] oci does not support enabling/disabling integrity check. Apr 17, 2018
@jonny7 jonny7 changed the title Codeception: [yii\base\NotSupportedException] oci does not support enabling/disabling integrity check. Codeception: Using Fixtures -> [yii\base\NotSupportedException] oci does not support enabling/disabling integrity check. Apr 17, 2018
@samdark
Copy link
Member

samdark commented Apr 17, 2018

@jonny7 it's mentioned at https://codeception.com/for/yii:

cleanup: false # don't wrap test in transaction

@samdark samdark closed this as completed Apr 17, 2018
@jonny7
Copy link
Contributor Author

jonny7 commented Apr 18, 2018

Hi @samdark

I had changed those and I still get the same error. I will post my relevant code and then you can see if I have made a mistake :)

codeception.yml

actor: Tester
paths:
    tests: tests
    log: tests/bamboo
    data: tests/_data
    helpers: tests/_support
settings:
    bootstrap: _bootstrap.php
    memory_limit: 1024M
    colors: true
modules:
    config:
        Yii2:
            configFile: 'config/web.php'

# To enable code coverage:
coverage:
    #c3_url: http://localhost/ccns-reporting/c3.php
    enabled: true
    #remote: true
    #remote_config: '/codeception.yml'
    include:
    # all my areas to test

Functional.suite.yml

# Codeception Test Suite Configuration

# suite for functional (integration) tests.
# emulate web requests and make application process them.
# (tip: better to use with frameworks).

# RUN `build` COMMAND AFTER ADDING/REMOVING MODULES.
#basic/web/index.php
class_name: FunctionalTester
modules:
    enabled:
      - Asserts
      - Filesystem
      - Yii2:
          configFile: 'config/web.php'
          part: [orm, fixtures]
          #configFile required - the path to the application config file. File should be configured for test environment and return configuration array.
          #entryUrl - initial application url (default: http://localhost/index-test.php).
          #entryScript - front script title (like: index-test.php). If not set - taken from entryUrl.
          transaction: false   #(default: true) wrap all database connection inside a transaction and roll it back after the test. Should be disabled for acceptance testing..
          cleanup: false       #(default: true) cleanup fixtures after the test        

I have changed different cleanup and transaction combinations and every time I've changed them, I've rebuilt the suite with vendor/bin/codecept run

ProcessorCest

<?php

// load fixtures
use app\tests\fixtures\ProcessFixture;

class ProcessorCest
{
    private $document;

    public function _fixtures()
    {
        return [
            'documents' => [
                'class' => ProcessFixture::className(),
                // fixture data located in tests/_data/user.php
                'dataFile' => codecept_data_dir() . 'PROCESS.php'
            ],
        ];
    }

    public function testManuallyLoadedButton(\FunctionalTester $I)
    {
        $document = $I->grabFixture('documents', 'document1');
        $I->amLoggedInAs(\app\models\User::findByEmail('me@company.com'));
        $I->seeRecord('app\modules\documents\models\Process', ['ID' => $document->ID]);
    }

I'm using an Oracle 11g for my test database.
I have a constraint on one column, which is 11g's way of building an auto-incrementing column. https://stackoverflow.com/a/11296469/895169. My fixture left this column blank as noted in the Yii docs.

I wanted to use Fixtures as it seems much cleaner.

@jonny7 jonny7 changed the title Codeception: Using Fixtures -> [yii\base\NotSupportedException] oci does not support enabling/disabling integrity check. Codeception: oci does not support enabling/disabling integrity check. Apr 18, 2018
@jonny7
Copy link
Contributor Author

jonny7 commented Apr 19, 2018

I am still having the same error with this having made @samdark suggestion. So I feel that either, there is a potential bug/exception to doing something with OCI. Or, that there needs to be a bit clearer documentation around this if the fix is something else. I am a huge fan of Yii, been using it since Yii1, brought Yii2 to my work too and a big fan of Codeception too. Not sure who actively is monitoring Github has of right now, so including @cebe @SilverFire

:-)

@samdark samdark reopened this Apr 19, 2018
@samdark
Copy link
Member

samdark commented Apr 19, 2018

@SamMousa could it be connected with recent changes?

@jonny7
Copy link
Contributor Author

jonny7 commented Apr 19, 2018

@samdark Thanks for re-opening for me. I do really appreciate it. I always do my best to answer these questions myself, through the going through the code or docs, but I can't figure this one out. I also know that Oracle is a more difficult DB to use and not as commonly used with PHP.

Thanks again

@SamMousa
Copy link
Contributor

Not sure, stack trace of the exception would be great.

@jonny7
Copy link
Contributor Author

jonny7 commented Apr 19, 2018

@SamMousa @samdark

Apologies for leaving it out

[yii\base\NotSupportedException] oci does not support enabling/disabling integrity check.

#1 C:\xampp-7\htdocs\www\vendor\yiisoft\yii2\db\QueryBuilder.php:1053
#2 C:\xampp-7\htdocs\www\vendor\yiisoft\yii2\db\Command.php:959
#3 C:\xampp-7\htdocs\www\vendor\yiisoft\yii2\test\InitDbFixture.php:96
#4 C:\xampp-7\htdocs\www\vendor\yiisoft\yii2\test\InitDbFixture.php:78
#5 C:\xampp-7\htdocs\www\vendor\yiisoft\yii2\test\FixtureTrait.php:117
#6 C:\xampp-7\htdocs\www\vendor\symfony\event-dispatcher\EventDispatcher.php:212
#7 C:\xampp-7\htdocs\www\vendor\symfony\event-dispatcher\EventDispatcher.php:44

When --debug and -vvv I also get

Scenario --
Destroying application
Starting application
[Fixtures] Loading fixtures
ERROR
Suite done, restoring $_SERVER to original

Relevant Composer require also:

		"codeception/codeception" : "^2.4",
		"codeception/specify" : "^1.0",
		"codeception/verify" : "^1.0",
		"codeception/phpunit-wrapper" : "7.1.0" #https://github.com/Codeception/Codeception/issues/4925

@SamMousa
Copy link
Contributor

SamMousa commented Apr 19, 2018

It seems upon unloading fixtures checkIntegrity is called, this causes the exception.

I haven't touched the fixtures part and am not sure what (if anything) has changed with respect to unloading fixtures.

Could it be that cleanup: false is not being respected?

@samdark
Copy link
Member

samdark commented Apr 19, 2018

Yes.

@SamMousa
Copy link
Contributor

SamMousa commented Apr 19, 2018

I think it's the unloading before loading:

https://github.com/Codeception/Codeception/blame/2.4/src/Codeception/Module/Yii2.php#L520

@jonny7 could you check your previous working version?

@jonny7
Copy link
Contributor Author

jonny7 commented Apr 19, 2018

Thanks @SamMousa

I only just started converted some tests to use fixtures properly. But I can update my composer to reflect what is needed and try again.

What changes should I make to my composer.json?

@SamMousa
Copy link
Contributor

None, it is a bug but it had existed for at least a year. I'll get back to you

@jonny7
Copy link
Contributor Author

jonny7 commented Apr 19, 2018

Thanks @SamMousa and @samdark for looking into this. Hopefully not too hard to fix

@SamMousa
Copy link
Contributor

@samdark I think the solution is to wrap the code in InitDbFixture::checkIntegrity() in a try .. catch, that way integrity checks are toggled for databases that support it, and nothing happens for other DBMSes.

@jonny7
Copy link
Contributor Author

jonny7 commented Apr 20, 2018

@SamMousa @samdark

I wrapped the $this->db->createCommand()->checkIntegrity($check, $schema)->execute(); in a try ... catch and got the following:

OCIStmtExecute: ORA-00911: invalid character
(ext\pdo_oci\oci_statement.c:159)
The SQL being executed was: DROP SEQUENCE "PROCESS_SEQ";CREATE SEQUENCE "PROCESS_SEQ" START WITH 1 INCREMENT BY 1 NOMAXVALUE NOCACHE

But if you had a work-around I could use until an official fix, that would be great!

@jonny7
Copy link
Contributor Author

jonny7 commented Apr 25, 2018

Any ideas on the on a timeline for this fix? 😄

@SamMousa
Copy link
Contributor

Feel free to create a PR, since I don't use this and I didn't cause this, it doesn't have high priority for me.
I'll unsub from this thread, good luck with your issue!

@jonny7
Copy link
Contributor Author

jonny7 commented May 4, 2018

Hi @samdark

Could we get a bug tag added here, just so it's on people's radar.

thanks 😄

@samdark samdark added the type:bug Bug label May 4, 2018
@CedricYii
Copy link
Contributor

@jonny7 for this error:
OCIStmtExecute: ORA-00911: invalid character (ext\pdo_oci\oci_statement.c:159) The SQL being executed was: DROP SEQUENCE "PROCESS_SEQ";CREATE SEQUENCE "PROCESS_SEQ" START WITH 1 INCREMENT BY 1 NOMAXVALUE NOCACHE
You could use PR #16362

@jonny7
Copy link
Contributor Author

jonny7 commented Jun 4, 2018

@CedricYii That error is really for a suggestion as to what might be able to stop the subject of this ticket erroring. I'm watching your PR now and will certainly see when it's merged in if it helps this problem.

Thanks

@Aevis
Copy link

Aevis commented Dec 16, 2019

I just stumbled upon this trying to use fixtures with an IBM Informix database. A quick workaround is to copy the InitDbFixture class from vendor/yiisoft/yii2/test into your application. Then use Composers files feature to tell it to use yours instead:

"autoload": {
        "exclude-from-classmap": [
            "vendor/yiisoft/yii2/test/InitDbFixture.php"
        ],
        "files": ["path/to/your/InitDbFixture.php"]
},

In your InitDbFixture class comment the checkIntegrity() function body out.

@ailxsey
Copy link

ailxsey commented Jun 5, 2024

I get the same problem. I want possible to disable/enabled checkIntegrity. Or don't apply global fixture InitDbFixture.

@terabytesoftw
Copy link
Member

We can simply run checkIntegrity() on drivers PDO that support the method, without using try catch, it will work correctly.

@terabytesoftw
Copy link
Member

I get the same problem. I want possible to disable/enabled checkIntegrity. Or don't apply global fixture InitDbFixture.

You could try this PR, this should solve the problem correctly.

@samdark samdark added this to the 2.2.0 milestone Jun 6, 2024
@samdark samdark modified the milestones: 2.2.0, 2.0.50.1 Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants