R
R
rumasterov2015-10-19 12:12:01
Yii
rumasterov, 2015-10-19 12:12:01

How to not load fixtures for some tests from a suite in Yii2?

Testing the active record model:

class OrderTest extends DbTestCase
{
    /** @var Order */
    private $order;

    public function setUp()
    {
        parent::setUp();
        $this->order = new Order();
    }

    public function fixtures()
    {
        return [
            'order' => OrderFixture::className(),
        ];
    }

    public function testGetPrice()
    {
        $this->order->price = 500;
        $this->assertEquals(500, $this->order->getPrice());
    }

    public function testCanRetrieveAnOrderByItsId()
    {
        /** @var Order $order */
        $order = Order::findOne(['id' => 1]);

        $this->assertTrue($order instanceof Order);
        $this->assertNotNull($order);
    }
}

The testCanRetrieveAnOrderByItsId method needs fixtures, but the testGetPrice method does not, how can one of the methods not load fixtures?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2015-10-19
@rumasterov

Can you move tests that don't use fixture to another test?

A
Anton Natarov, 2015-10-19
@HanDroid

Comment out method ?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question