S
S
slip312019-04-24 22:59:13
Yii
slip31, 2019-04-24 22:59:13

Why doesn't the delete test pass?

unit test. Trying to start testing (Yii2)
Made fixtures

public function _fixtures() {
        return [
            'menu' => [
                'class' => \common\fixtures\MenuFixture::className(),
                'dataFile' => codecept_data_dir() . 'menu.php'
            ]
        ];
    }

Filled out the file menu.php
Made a creation test
public function testCreateMenuItem() {
        $model = new Menu([
            'label' => 'Контакты',
            'url' => 'contacts',
            'order' => '8',
            'created_at' => '1402312317',
            'updated_at' => '1402312317',
            'delete_at' => '0',
        ]);
        $this->assertTrue($model->validate());
        $this->assertTrue($model->save());
    }

Everything seems to be ok (but as I understand it, fixtures are not involved here)
I am doing a test for deletion
public function testDeleteMenuItem() {        
        $model = Menu::findOne(1);      
        $this->assertTrue($model->delete());
    }

But it fails when running codecept --debug
Failed asserting that 1 is true.
MenuTest: Delete menu item  Destroying application
  Starting application
  [ConnectionWatcher] watching new connections
  [Fixtures] Loading fixtures
  [ConnectionWatcher] watching new connections
  [yii\db\Connection::open] 'Opening DB connection: mysql:host=localhost;dbname=may_test'
  [ConnectionWatcher] Connection opened!
  [ConnectionWatcher] Connection opened!
  [ConnectionWatcher] no longer watching new connections
  [ConnectionWatcher] closing all (1) connections
  [Fixtures] Done
  [TransactionForcer] watching new connections
  [yii\db\Connection::open] 'Opening DB connection: mysql:host=localhost;dbname=may_test'
  [ConnectionWatcher] Connection opened!
  [TransactionForcer] Connection opened!
  [TransactionForcer] Transaction started for: mysql:host=localhost;dbname=may_test
x MenuTest: Delete menu item (0.03s)
  [TransactionForcer] Transaction cancelled; all changes reverted.
  [TransactionForcer] no longer watching new connections
  Destroying application
  [ConnectionWatcher] no longer watching new connections
  [ConnectionWatcher] closing all (2) connections
  Suite done, restoring $_SERVER to original

Why doesn't it pass?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question