Permalink
Browse files

string length validator and tests

  • Loading branch information...
1 parent 6e9c2c9 commit e6564c995ebda6504c8be68fd56220cbba231010 Michael Ridgway committed Jul 16, 2010
No changes.
@@ -1,7 +0,0 @@
-auxiliary.org-netbeans-modules-web-client-tools-api.clientdebug=false
-auxiliary.org-netbeans-modules-web-client-tools-api.FIREFOX=true
-auxiliary.org-netbeans-modules-web-client-tools-api.INTERNET_5f_EXPLORER=false
-auxiliary.org-netbeans-modules-web-client-tools-api.serverdebug=true
-copy.src.files=false
-copy.src.target=
-run.as=LOCAL
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project-private xmlns="http://www.netbeans.org/ns/project-private/1">
- <coverage xmlns="http://www.netbeans.org/ns/code-coverage/1" enabled="true"/>
- <editor-bookmarks xmlns="http://www.netbeans.org/ns/editor-bookmarks/1"/>
-</project-private>
@@ -21,13 +21,24 @@ public function setUp()
public function testRepositoryReturnsElement()
{
$repo = $this->_fm->getRepository('Test\Model\Article');
- $this->assertTrue($repo->getElement('title') instanceof \Zend_Form_Element);
+ $element = $repo->getElement('title');
+ $this->assertTrue($element instanceof \Zend_Form_Element);
+ }
+
+ public function testRepositoryValidators()
+ {
+ $repo = $this->_fm->getRepository('Test\Model\Article');
+ $element = $repo->getElement('title');
+
+ $stringLengthValidator = $element->getValidator('StringLength');
+ $this->assertEquals(255, $stringLengthValidator->getMax());
}
public function testRepositoryReturnsForm()
{
$repo = $this->_fm->getRepository('Test\Model\Article');
- $this->assertTrue($repo->getForm() instanceof \Zend_Form);
+ $form = $repo->getForm();
+ $this->assertTrue($form instanceof \Zend_Form);
}
}
@@ -18,13 +18,6 @@ class Article extends AbstractModel
/**
* @var string
- * @Column(type="string", name="slug", nullable="false", length="255", unique="true")
- * @Element(type="text", name="slug", required="false", minLength="5")
- */
- protected $slug;
-
- /**
- * @var string
* @Column(type="string", name="title", nullable="false", length="255")
* @Element(type="text", name="title", required="true", minLength="5", maxLength="255")
*/
@@ -61,7 +54,6 @@ class Article extends AbstractModel
public function __construct($title, $content = '', $date = null, $published = false)
{
$this->setTitle($title);
- $this->setSlug($this->slug($title));
$this->setContent($content);
$this->setDate($date);
$this->setPublished($published);
@@ -99,35 +91,4 @@ public function setPublished($published = true)
$this->published = $published;
return $this;
}
-
- /**
- * Returns abbreviated content text
- *
- * @return string
- */
- public function getShortContent()
- {
- return $this->getContent();
- }
-
- /**
- * Returns the url to view the inidividual article
- *
- * @return string
- */
- public function getUrl()
- {
- $d = $this->getDate();
- return '/view/' . $this->getSlug() . '/';
- }
-
- /**
- * @param string $value
- * @return string
- */
- protected function slug($value)
- {
- $filter = new \Blog\Filter\Slug($this->getRepository(), 'findBySlug');
- return $filter->filter(substr($value, 0, 255));
- }
}

0 comments on commit e6564c9

Please sign in to comment.