public function setUp()
 {
     $this->fixtures('unit_tests', 'unit_tests_more');
     // paginated collection from array
     $files = array(new File(1, 'alpha'), new File(2, 'beta'), new File(3, 'gamma'), new File(4, 'delta'), new File(5, 'epsilon'), new File(6, 'zeta'), new File(7, 'eta'), new File(8, 'theta'), new File(9, 'iota'), new File(10, 'kappa'), new File(11, 'lamda'), new File(12, 'mu'), new File(13, 'nu'), new File(14, 'xi'), new File(15, 'omikron'), new File(16, 'pi'), new File(17, 'rho'), new File(18, 'sigma'), new File(19, 'tau'), new File(20, 'upsilon'), new File(21, 'phi'), new File(22, 'chi'), new File(23, 'psi'), new File(24, 'omega'));
     $this->_array = new Mad_Model_PaginatedCollection(array_slice($files, 10, 5), 3, 5, count($files));
     // paginated collection from model collection
     $testCount = UnitTest::count();
     $tests = UnitTest::find('all', array('offset' => '5', 'limit' => '5'));
     $this->_models = new Mad_Model_PaginatedCollection($tests, 2, 5, $testCount);
 }
Пример #2
0
 public function testEmailValidation()
 {
     $this->fixtures('unit_tests');
     $test = UnitTest::find(1);
     $test->email_value = 'asdf';
     $this->assertFalse($test->isValid());
     $this->assertTrue($test->errors->isInvalid('email_value'));
     $this->assertEquals(1, count($test->errors->on('email_value')));
     $this->assertFalse($test->save());
 }
Пример #3
0
 public function testUniqueUpdateInvalid()
 {
     $this->fixtures('unit_tests');
     $this->model = UnitTest::find(1);
     $options = array();
     $validation = Mad_Model_Validation_Base::factory('uniqueness', 'string_value', $options);
     $this->model->string_value = 'name b';
     $validation->validate('save', $this->model);
     $this->assertEquals(array('has already been taken'), $this->model->errors->on('string_value'));
 }
Пример #4
0
 public function testShouldSerializeBinary()
 {
     $xml = UnitTest::find(1)->toXml();
     $this->assertContains('c29tZSBibG9iIGRhdGE=</blob-value>', $xml);
     $this->assertContains('<blob-value encoding="base64" type="binary">', $xml);
 }
Пример #5
0
 public function testBeforeUpdateException()
 {
     try {
         $test = UnitTest::find(1);
         $test->updateAttributes(array('integer_value' => '123', 'string_value' => 'before update test'));
         $test->saveEx();
         $this->fail();
     } catch (Mad_Model_Exception_Validation $e) {
         // validation errors
         $this->assertEquals(1, count($test->errors));
         foreach ($test->errors->fullMessages() as $msg) {
             $this->assertEquals('String value cannot be renamed to before update test', $msg);
         }
     }
 }
Пример #6
0
 public function testRenderPartialModelCollection()
 {
     $this->fixtures('unit_tests');
     $this->_view->myObjects = UnitTest::find('all', array('limit' => 2));
     $expected = '<div><p>name a</p><p>name b</p></div>';
     $this->assertEquals($expected, $this->_view->render('testPartialCollection'));
 }