/** @test */ public function fixtures_are_loaded_into_database_as_expected() { $order = Order::where(['address' => 'Test address'])->firstOrFail(); $this->assertEquals(count($this->getFixture('order')), count(Order::all())); $this->assertInstanceOf(Order::class, $order); $this->assertEquals('Test address', $order->address); }
/** * Creates and seeds the order table. */ protected function createAndSeedOrdersTable() { /* * @var $db Manager */ $this->db = Yii::$app->db; $this->db->schema()->create('order', function ($table) { $table->increments('id'); $table->string('name')->unique(); $table->timestamps(); }); Order::create(['name' => 'Test address']); Order::create(['name' => 'Another test Address']); }
/** @test */ public function it_gives_the_errors_to_active_form_normally() { ob_start(); ob_implicit_flush(false); $form = new ActiveForm(['action' => '/something']); $order = new Order(); $order->validate(); echo $form->field($order, 'address'); $content = ob_get_clean(); $this->assertContains('Address cannot be blank', $content); }