Giter Site home page Giter Site logo

Missing alias @tests about yii2-app-template HOT 8 CLOSED

2amigos avatar 2amigos commented on May 25, 2024
Missing alias @tests

from yii2-app-template.

Comments (8)

pana1990 avatar pana1990 commented on May 25, 2024

@tonydspaniard this issue is not fixed yet. why do you close it?

from yii2-app-template.

tonydspaniard avatar tonydspaniard commented on May 25, 2024

@pana1990 speed reviewing...

from yii2-app-template.

tonydspaniard avatar tonydspaniard commented on May 25, 2024

@pana1990 when you create a new migration, you should run composer update as it heavily relies on composer autoloader. Have you done the composer update so it recreates its class names?

from yii2-app-template.

pana1990 avatar pana1990 commented on May 25, 2024

i think that the problem is missing @tests alias.

i am going to try again explain the problem :

1º i create fresh project with composer.
2º i create the following migration :

<?php

use yii\db\Migration;

/**
 * Handles the creation of table `post`.
 */
class m170731_035905_create_post_table extends Migration
{
    /**
     * @inheritdoc
     */
    public function up()
    {
        $this->createTable('post', [
            'id' => $this->primaryKey(),
            'title' => $this->string(),
            'content' => $this->text(),
        ]);
    }

    /**
     * @inheritdoc
     */
    public function down()
    {
        $this->dropTable('post');
    }
}

3º run yii migrate // it works.
4º i create the following fixture in tests/fixtures/PostFixture.php

<?php

namespace tests\fixtures;

class PostFixture extends ActiveFixture
{
    public $modelClass = 'app\models\Post';
}

5º i create data to postfixture in tests/fixtures/data/post.php

<?php

return [
    [
        'id' => 1,
        'title' => 'title 1',
        'content' => 'content 1',
    ],
    [
        'id' => 2,
        'title' => 'title 2',
        'content' => 'content 2',
    ],
];

6º i config controllerMap to custom my namespace fixture in config/console/app.php

'controllerMap' => [
        'fixture' => [
            'class' => 'yii\console\controllers\FixtureController',
            'namespace' => 'tests\fixtures',
        ],
    ]

7º i run yii fixture "*" and this command fails :
fails

if i add the following alias it works :

<?php

use SideKit\Config\ConfigKit;
/*
 * --------------------------------------------------------------------------
 * Register custom Yii aliases
 * --------------------------------------------------------------------------
 *
 * As we have changed the structure. Modify default Yii aliases here.
 */
Yii::setAlias('@tests', ConfigKit::config()->getBasePath() . DIRECTORY_SEPARATOR . '../tests');
Yii::setAlias('@root', ConfigKit::config()->getRootPath());
Yii::setAlias('@web', ConfigKit::config()->getBasePath() . DIRECTORY_SEPARATOR . '../public');

Maybe it's better include this alias in config console, can i send pr to fix this issue?

from yii2-app-template.

tonydspaniard avatar tonydspaniard commented on May 25, 2024

@pana1990 you are totally correct. I don't think the @tests alias could damage anyhow the rest of the app. So I think bootstrap/aliases.php is the best place to add it. Please, proceed (do not forget to add that change on CHANGE_LOG.

Thanks you for your work on this template.

from yii2-app-template.

tonydspaniard avatar tonydspaniard commented on May 25, 2024

On another note, shouldn't you be using $ ./tests/bin/yii instead?

from yii2-app-template.

pana1990 avatar pana1990 commented on May 25, 2024

if i want to seed my dev db i need to use yii, isn't it?

from yii2-app-template.

tonydspaniard avatar tonydspaniard commented on May 25, 2024

I use database dumps: http://codeception.com/docs/modules/Db

from yii2-app-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.