public function getParent() { return $this->hasOne(Category::className(), ['id' => 'parent_category_id']); }
public function testQuoting() { $this->assertEmpty(Category::findOne("'")); $this->assertEmpty(Category::find()->ancestorsOf("'")->all()); $this->assertEmpty(Category::find()->childrenOf("'")->all()); $this->assertEmpty(Category::find()->parentOf("'")->all()); $this->assertEmpty(Category::find()->deleteNode("'")); $this->assertEmpty(Category::find()->descendantsOf("'")->all()); $this->assertEmpty(Category::find()->fullPathOf("'")->all()); $this->assertEmpty(Category::find()->pathOf("'")->all()); $this->assertEmpty(Category::find()->unorderedPathOf("'")->all()); /** @var Category $folder5 */ $category5 = Category::findOne(5); try { $category5->moveTo("'"); $this->fail(); } catch (\Exception $e) { $this->assertEquals(201, $e->getCode()); } $newCategory = new Category(); $newCategory->name = 'Category'; $this->assertTrue($newCategory->save()); $this->assertEquals(1, $newCategory->appendTo("'")); try { Category::find()->markAsRoot("'"); $this->fail(); } catch (\Exception $e) { // http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html $this->assertEquals('1452', $e->errorInfo[1]); } }