Example #1
0
 /**
  * @covers Amiss\Sql\Manager::groupBy
  */
 public function testGroupBy()
 {
     $deps = Test\Factory::managerModelDemo();
     $indexed = $deps->manager->groupBy($this->objects, 'name');
     $expected = ['a' => [$this->objects[0]], 'b' => [$this->objects[1], $this->objects[2]]];
     $this->assertEquals($expected, $indexed);
 }
 public function setUp()
 {
     $this->deps = Test\Factory::managerModelDemo();
     $this->manager = $this->deps->manager;
     $this->artist = $this->manager->get(Demo\Artist::class, 'artistId=?', array(1));
     $this->assertEquals('Limozeen', $this->artist->name);
 }
Example #3
0
 /**
  * Ensures the signature for table insertion works
  *   Amiss\Sql\Manager->insert( string $table , array $values )
  * 
  * @group acceptance
  * @group manager
  */
 public function testInsertTable()
 {
     $deps = Test\Factory::managerModelDemo();
     $this->assertEquals(0, $deps->manager->count(Demo\Artist::class, 'slug="insert-table-test"'));
     $id = $deps->manager->insertTable(Demo\Artist::class, array('name' => 'Insert Table Test', 'slug' => 'insert-table-test', 'artistTypeId' => 1));
     $this->assertGreaterThan(0, $id);
     $this->assertEquals(1, $deps->manager->count(Demo\Artist::class, 'slug="insert-table-test"'));
 }
 public function setUp()
 {
     $this->deps = Test\Factory::managerModelDemo();
     $this->manager = $this->deps->manager;
     $this->artist = $this->deps->manager->get(Demo\Artist::class, 'artistId=?', array(1));
     if (!$this->artist) {
         throw new \UnexpectedValueException("Unexpected test data");
     }
 }
Example #5
0
 /**
  * @covers Amiss\Sql\Manager::indexBy
  */
 public function testIndexByAllowedNulls()
 {
     $deps = Test\Factory::managerModelDemo();
     $obj1 = new \Amiss\Demo\Artist();
     $obj1->name = null;
     $obj2 = new \Amiss\Demo\Artist();
     $obj2->name = 'a';
     $indexed = $deps->manager->indexBy([$obj1, $obj2], 'name', null, null, !'ignoreNulls');
     $expected = ['' => $obj1, 'a' => $obj2];
     $this->assertEquals($expected, $indexed);
 }
Example #6
0
 public function setUp()
 {
     $this->deps = Test\Factory::managerModelDemo();
     $this->manager = $this->deps->manager;
 }