public function setUp()
 {
     parent::setUp();
     \Amiss\Sql\ActiveRecord::_reset();
     $this->connector = new \Amiss\Test\Helper\TestConnector('mysql:xx');
     $this->mapper = \Amiss\Sql\Factory::createMapper(array());
     $this->manager = new \Amiss\Sql\Manager($this->connector, $this->mapper);
     \Amiss\Sql\ActiveRecord::setManager($this->manager);
     $this->class = __NAMESPACE__ . '\\TestCreateCustomTypeWithEmptyColumnTypeRecord';
 }
예제 #2
0
 /**
  * @covers Amiss\Sql\ActiveRecord::__callStatic
  */
 public function testAssignRelatedStaticArray()
 {
     $manager = $this->getMock('Amiss\\Sql\\Manager', array('getRelated'), array($this->deps->connector, $this->deps->mapper));
     $manager->relators = \Amiss\Sql\Factory::createRelators();
     \Amiss\Sql\ActiveRecord::setManager($manager);
     $child1 = new TestRelatedChild();
     $child1->childId = 6;
     $child1->parentId = 1;
     $child2 = new TestRelatedChild();
     $child2->childId = 7;
     $child2->parentId = 2;
     $input = [$child1, $child2];
     $manager->expects($this->once())->method('getRelated')->with($this->equalTo($input), $this->equalTo('parent'))->will($this->returnValue([999, 777]));
     TestRelatedChild::assignRelated($input, 'parent');
     $this->assertEquals(999, $child1->parent);
     $this->assertEquals(777, $child2->parent);
 }
 public function tearDown()
 {
     \Amiss\Sql\ActiveRecord::_reset();
     $this->deps = null;
     parent::tearDown();
 }