public function testConfiguration() { $post = new Post(); $post->detachBehavior('ml'); try { $post->attachBehavior('ml', ['class' => MultilingualBehavior::className(), 'languages' => []]); $this->fail("Expected exception not thrown"); } catch (InvalidConfigException $e) { $this->assertEquals(101, $e->getCode()); } try { $post->detachBehavior('ml'); $post->attachBehavior('ml', ['class' => MultilingualBehavior::className(), 'languages' => 'Some value']); $this->fail("Expected exception not thrown"); } catch (InvalidConfigException $e) { $this->assertEquals(101, $e->getCode()); } try { $post->detachBehavior('ml'); $post->attachBehavior('ml', ['class' => MultilingualBehavior::className(), 'languages' => ['ru' => 'Russian', 'en-US' => 'English'], 'langForeignKey' => 'post_id', 'tableName' => "{{%postLang}}"]); $this->fail("Expected exception not thrown"); } catch (InvalidConfigException $e) { $this->assertEquals(103, $e->getCode()); } try { $post->detachBehavior('ml'); $post->attachBehavior('ml', ['class' => MultilingualBehavior::className(), 'languages' => ['ru' => 'Russian', 'en-US' => 'English'], 'attributes' => ['title', 'body']]); $this->fail("Expected exception not thrown"); } catch (InvalidConfigException $e) { $this->assertEquals(105, $e->getCode()); } $post->detachBehavior('ml'); $post->attachBehavior('ml', ['class' => MultilingualBehavior::className(), 'languages' => ['ru' => 'Russian', 'en-US' => 'English'], 'langForeignKey' => 'post_id', 'attributes' => ['title', 'body']]); $this->assertNotNull($post->defaultLanguage); }