/** * Test getting associations by property. * * @return void */ public function testGetByProperty() { $belongsTo = new BelongsTo('Users', []); $this->assertEquals('user', $belongsTo->property()); $this->associations->add('Users', $belongsTo); $this->assertNull($this->associations->get('user')); $this->assertSame($belongsTo, $this->associations->getByProperty('user')); }
/** * Test that plugin names are omitted from property() * * @return void */ public function testPropertyNoPlugin() { $mock = $this->getMock('Cake\\ORM\\Table', [], [], '', false); $config = ['sourceTable' => $this->client, 'targetTable' => $mock]; $association = new BelongsTo('Contacts.Companies', $config); $this->assertEquals('company', $association->property()); }
/** * Test that plugin names are omitted from property() * * @return void */ public function testPropertyNoPlugin() { $mock = $this->getMockBuilder('Cake\\ORM\\Table')->disableOriginalConstructor()->getMock(); $config = ['sourceTable' => $this->client, 'targetTable' => $mock]; $association = new BelongsTo('Contacts.Companies', $config); $this->assertEquals('company', $association->property()); }
/** * Test getting associations by property. * * @return void */ public function testGetByProperty() { $table = $this->getMockBuilder('Cake\\ORM\\Table')->setMethods(['table'])->getMock(); $table->schema([]); $belongsTo = new BelongsTo('Users', ['sourceTable' => $table]); $this->assertEquals('user', $belongsTo->property()); $this->associations->add('Users', $belongsTo); $this->assertNull($this->associations->get('user')); $this->assertSame($belongsTo, $this->associations->getByProperty('user')); }