Thread: [Argil-svn] SF.net SVN: argil: [541] branches/experimental (Page 2)
Status: Alpha
Brought to you by:
tswicegood
|
From: <tsw...@us...> - 2007-05-31 00:00:32
|
Revision: 541
http://argil.svn.sourceforge.net/argil/?rev=541&view=rev
Author: tswicegood
Date: 2007-05-30 17:00:32 -0700 (Wed, 30 May 2007)
Log Message:
-----------
Add the first pass at a generic Model Locator
Added Paths:
-----------
branches/experimental/src/Argil/Model/Locator.php
branches/experimental/tests/Argil/Model/LocatorTest.php
Added: branches/experimental/src/Argil/Model/Locator.php
===================================================================
--- branches/experimental/src/Argil/Model/Locator.php (rev 0)
+++ branches/experimental/src/Argil/Model/Locator.php 2007-05-31 00:00:32 UTC (rev 541)
@@ -0,0 +1,47 @@
+<?php
+
+require_once 'Argil/Model/Container.php';
+require_once 'Argil/Util/Template/CamelCapsToUnderscore.php';
+class Argil_Model_Locator
+{
+ private $_pdo = null;
+
+ public function __construct(PDO $pdo)
+ {
+ $this->_pdo = $pdo;
+ }
+
+ public function __call($method, $arguments)
+ {
+ if (preg_match('/^findBy(.+)$/', $method, $matches)) {
+ $property = new Argil_Util_Template_CamelCapsToUnderscore($matches[1]);
+ $value = array_shift($arguments);
+ $model = array_shift($arguments);
+ return $this->_findByGivenProperty((string)$property, $value, $model);
+ }
+ }
+
+ public function findById($id, $model)
+ {
+ $meta = new Argil_Model_Container($model);
+ return $this->_findByGivenProperty($meta->getPrimaryKey(), $id, $model);
+ }
+
+ private function _findByGivenProperty($property, $value, $model)
+ {
+ $meta = new Argil_Model_Container($model);
+ $statement = $this->_pdo->prepare(
+ "SELECT * FROM {$meta->getTable()} WHERE {$property} = :value"
+ );
+
+ $statement->execute(array(
+ ':value' => $value
+ ));
+
+ $data = $statement->fetch(PDO::FETCH_ASSOC);
+ foreach ($data as $key => $value) {
+ $model->$key = $value;
+ }
+ return new Argil_Model_Container($model);
+ }
+}
\ No newline at end of file
Added: branches/experimental/tests/Argil/Model/LocatorTest.php
===================================================================
--- branches/experimental/tests/Argil/Model/LocatorTest.php (rev 0)
+++ branches/experimental/tests/Argil/Model/LocatorTest.php 2007-05-31 00:00:32 UTC (rev 541)
@@ -0,0 +1,101 @@
+<?php
+
+require_once dirname(__FILE__) . '/../../config.php';
+require_once 'Argil/Model/Locator.php';
+
+/**
+ * @table person
+ */
+class SimpleArgilPerson
+{
+
+}
+
+class Argil_Model_LocatorTest extends UnitTestCase
+{
+ private $_pdo = null;
+ private $_random = '';
+ public function setup()
+ {
+ $pdo = new PDO('sqlite::memory:');
+ $this->assertTrue(
+ $pdo->exec('CREATE TABLE person (
+ person_id INT,
+ first_name VARCHAR(50),
+ last_name VARCHAR(100)
+ )'
+ ) !== false,
+ 'sanity check - make sure the table is setup properly'
+ );
+
+ $this->assertTrue(
+ $pdo->exec(
+ "INSERT INTO person VALUES ('1', 'Travis', 'Swicegood')"
+ ) !== false,
+ 'sanity check - make sure the rows are inserted'
+ );
+
+ $this->_random = 'Random, ' . rand(1, 10);
+ $this->assertTrue(
+ $pdo->exec(
+ "INSERT INTO person VALUES ('2', 'Joe', '" . $this->_random . "')"
+ ) !== false,
+ 'sanity check - make sure the rows are inserted'
+ );
+ $this->_pdo = $pdo;
+ }
+
+ public function testUsedToLocateModelsInPersistentStorageAndReturnThemInModelContainers()
+ {
+
+ }
+
+ public function testRequiresPdoObjectAsFirstParameterAtInstantiation()
+ {
+ $reflection = new ReflectionClass('Argil_Model_Locator');
+ $param = array_shift($reflection->getConstructor()->getParameters());
+ $this->assertFalse($param->isOptional());
+ $this->assertEqual($param->getClass()->getName(), 'PDO');
+ }
+
+ public function testCanLocateAGivenModel()
+ {
+ $locator = new Argil_Model_Locator($this->_pdo);
+ $model = $locator->findById(1, new SimpleArgilPerson());
+ $this->assertIsA($model, 'Argil_Model_Container');
+ $this->assertTrue($model->is('SimpleArgilPerson'));
+ $this->assertEqual('Travis', $model->first_name);
+ $this->assertEqual('Swicegood', $model->last_name);
+ unset($model);
+
+ $model = $locator->findById(2, new SimpleArgilPerson());
+ $this->assertIsA($model, 'Argil_Model_Container');
+ $this->assertTrue($model->is('SimpleArgilPerson'));
+ $this->assertEqual('Joe', $model->first_name);
+ $this->assertEqual($this->_random, $model->last_name);
+ }
+
+ public function testCanUseFindByPropertyNameMethodToFindAnObject()
+ {
+ $locator = new Argil_Model_Locator($this->_pdo);
+ $model = $locator->findByFirstName('Travis', new SimpleArgilPerson());
+ $this->assertIsA($model, 'Argil_Model_Container');
+ $this->assertTrue($model->is('SimpleArgilPerson'));
+ $this->assertEqual('Travis', $model->first_name);
+ $this->assertEqual('Swicegood', $model->last_name);
+ unset($model);
+
+ $model = $locator->findByLastName('Swicegood', new SimpleArgilPerson());
+ $this->assertIsA($model, 'Argil_Model_Container');
+ $this->assertTrue($model->is('SimpleArgilPerson'));
+ $this->assertEqual('Travis', $model->first_name);
+ $this->assertEqual('Swicegood', $model->last_name);
+ unset($model);
+
+ $model = $locator->findByLastName($this->_random, new SimpleArgilPerson());
+ $this->assertIsA($model, 'Argil_Model_Container');
+ $this->assertTrue($model->is('SimpleArgilPerson'));
+ $this->assertEqual('Joe', $model->first_name);
+ $this->assertEqual($this->_random, $model->last_name);
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tsw...@us...> - 2007-06-01 23:54:06
|
Revision: 542
http://argil.svn.sourceforge.net/argil/?rev=542&view=rev
Author: tswicegood
Date: 2007-06-01 16:54:06 -0700 (Fri, 01 Jun 2007)
Log Message:
-----------
Add Argil_Util_System_Directory and appropriate tests
Added Paths:
-----------
branches/experimental/src/Argil/Util/System/
branches/experimental/src/Argil/Util/System/Directory/
branches/experimental/src/Argil/Util/System/Directory/Exception.php
branches/experimental/src/Argil/Util/System/Directory.php
branches/experimental/tests/Argil/Util/System/
branches/experimental/tests/Argil/Util/System/DirectoryTest.php
Added: branches/experimental/src/Argil/Util/System/Directory/Exception.php
===================================================================
--- branches/experimental/src/Argil/Util/System/Directory/Exception.php (rev 0)
+++ branches/experimental/src/Argil/Util/System/Directory/Exception.php 2007-06-01 23:54:06 UTC (rev 542)
@@ -0,0 +1,3 @@
+<?php
+
+class Argil_Util_System_Directory_Exception extends Exception { }
\ No newline at end of file
Added: branches/experimental/src/Argil/Util/System/Directory.php
===================================================================
--- branches/experimental/src/Argil/Util/System/Directory.php (rev 0)
+++ branches/experimental/src/Argil/Util/System/Directory.php 2007-06-01 23:54:06 UTC (rev 542)
@@ -0,0 +1,39 @@
+<?php
+
+require_once 'Argil/Util/System/Directory/Exception.php';
+
+class Argil_Util_System_Directory
+{
+ private $_path = null;
+
+ public function __construct($path)
+ {
+ if (!is_dir($path)) {
+ throw new Argil_Util_System_Directory_Exception('invalid path provided');
+ }
+
+ $this->_path = $path;
+ }
+
+ public function __get($key)
+ {
+ switch ($key) {
+ case 'path':
+ return $this->_path;
+ case 'real_path' :
+ return realpath($this->_path);
+ }
+ }
+
+ public function __set($key, $value)
+ {
+ throw new Argil_Util_System_Directory_Exception(
+ "attempting to set read-only {$key} property"
+ );
+ }
+
+ public function __toString()
+ {
+ return $this->_path;
+ }
+}
Added: branches/experimental/tests/Argil/Util/System/DirectoryTest.php
===================================================================
--- branches/experimental/tests/Argil/Util/System/DirectoryTest.php (rev 0)
+++ branches/experimental/tests/Argil/Util/System/DirectoryTest.php 2007-06-01 23:54:06 UTC (rev 542)
@@ -0,0 +1,76 @@
+<?php
+
+require_once dirname(__FILE__) . '/../../../config.php';
+require_once 'Argil/Util/System/Directory.php';
+
+class Argil_Util_System_DirectoryTest extends UnitTestCase
+{
+ public function testThrowsAnExceptionWhenProvidedWithInvalidDirectory()
+ {
+ try {
+ new Argil_Util_System_Directory(__FILE__);
+ $this->fail('exception not caught');
+ } catch (Argil_Util_System_Directory_Exception $e) {
+ $this->pass('Exception caught');
+ $this->assertEqual(
+ 'invalid path provided',
+ $e->getMessage()
+ );
+ }
+
+ new Argil_Util_System_Directory(dirname(__FILE__));
+ $this->pass('properly instantiated');
+ }
+
+ public function testHasReadOnlyPathProperty()
+ {
+ $path = new Argil_Util_System_Directory(dirname(__FILE__));
+ $this->assertEqual(dirname(__FILE__), $path->path);
+ unset($path);
+
+ $path = new Argil_Util_System_Directory(dirname(__FILE__) . '/..');
+ $this->assertEqual(dirname(__FILE__) . '/..', $path->path);
+
+ try {
+ $path->path = 'new value';
+ $this->fail('exception not caught');
+ } catch (Argil_Util_System_Directory_Exception $e) {
+ $this->pass('exception caught');
+ $this->assertEqual(
+ 'attempting to set read-only path property',
+ $e->getMessage()
+ );
+ }
+ }
+
+ public function testWhenCastToStringPathObjectEqualsPathProperty()
+ {
+ $path = new Argil_Util_System_Directory(dirname(__FILE__));
+ $this->assertEqual(dirname(__FILE__), (string)$path);
+ unset($path);
+
+ $path = new Argil_Util_System_Directory(dirname(__FILE__) . '/..');
+ $this->assertEqual(dirname(__FILE__) . '/..', (string)$path);
+ }
+
+ public function testHasReadOnlyRealpathProperty()
+ {
+ $path = new Argil_Util_System_Directory(dirname(__FILE__) . '/..');
+ $this->assertEqual(realpath(dirname(__FILE__) . '/..'), $path->real_path);
+ unset($path);
+
+ $path = new Argil_Util_System_Directory(dirname(__FILE__));
+ $this->assertEqual(dirname(__FILE__), $path->real_path);
+
+ try {
+ $path->real_path = 'new value';
+ $this->fail('exception not caught');
+ } catch (Argil_Util_System_Directory_Exception $e) {
+ $this->pass('exception caught');
+ $this->assertEqual(
+ 'attempting to set read-only real_path property',
+ $e->getMessage()
+ );
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tsw...@us...> - 2007-07-14 22:05:50
|
Revision: 543
http://argil.svn.sourceforge.net/argil/?rev=543&view=rev
Author: tswicegood
Date: 2007-07-14 15:05:46 -0700 (Sat, 14 Jul 2007)
Log Message:
-----------
Remove Argil_Pdo - should have already been committed
Removed Paths:
-------------
branches/experimental/src/Argil/Pdo.php
branches/experimental/tests/Argil/PdoTest.php
Deleted: branches/experimental/src/Argil/Pdo.php
===================================================================
--- branches/experimental/src/Argil/Pdo.php 2007-06-01 23:54:06 UTC (rev 542)
+++ branches/experimental/src/Argil/Pdo.php 2007-07-14 22:05:46 UTC (rev 543)
@@ -1,36 +0,0 @@
-<?php
-
-class Argil_Pdo
-{
- public function __construct() { }
-
- public function __sleep() { }
-
- public function __wakeup() { }
-
- public function beginTransaction() { }
-
- public function commit() { }
-
- public function errorCode() { }
-
- public function errorInfo() { }
-
- public function exec($statement) { }
-
- public function getAttribute($attribute) { }
-
- public function getAvailableDrivers() { }
-
- public function lastInsertId($name = null) { }
-
- public function prepare($string, array $driver_options = array()) { }
-
- public function query($statement, $p2 = null, $p3 = null, array $p4 = null) { }
-
- public function quote($string, $parameter_type = PDO::PARAM_STR) { }
-
- public function rollBack() { }
-
- public function setAttribute($attribute, $value) { }
-}
\ No newline at end of file
Deleted: branches/experimental/tests/Argil/PdoTest.php
===================================================================
--- branches/experimental/tests/Argil/PdoTest.php 2007-06-01 23:54:06 UTC (rev 542)
+++ branches/experimental/tests/Argil/PdoTest.php 2007-07-14 22:05:46 UTC (rev 543)
@@ -1,25 +0,0 @@
-<?php
-
-require_once dirname(__FILE__) . '/../config.php';
-require_once 'Argil/Pdo.php';
-
-class Argil_PdoTest extends UnitTestCase
-{
- public function testHasAllOfTheSameMethodsAsPdo()
- {
- $argil = new ReflectionClass('Argil_Pdo');
- $pdo = new ReflectionClass('PDO');
-
- $argilMethods = array();
- foreach ($argil->getMethods() as $argilMethod) {
- $argilMethods[] = $argilMethod->getName();
- }
-
- foreach ($pdo->getMethods() as $pdoMethod) {
- $this->assertTrue(
- in_array($pdoMethod->getName(), $argilMethods),
- "Checking that {$pdoMethod->getName()} is declared"
- );
- }
- }
-}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tsw...@us...> - 2007-07-14 22:09:33
|
Revision: 544
http://argil.svn.sourceforge.net/argil/?rev=544&view=rev
Author: tswicegood
Date: 2007-07-14 15:09:35 -0700 (Sat, 14 Jul 2007)
Log Message:
-----------
Add in Argil_Util_System_File code
Modified Paths:
--------------
branches/experimental/tests/AllTest.php
Added Paths:
-----------
branches/experimental/src/Argil/Util/System/File/
branches/experimental/src/Argil/Util/System/File/Exception.php
branches/experimental/src/Argil/Util/System/File.php
branches/experimental/tests/Argil/Util/System/FileTest.php
Added: branches/experimental/src/Argil/Util/System/File/Exception.php
===================================================================
--- branches/experimental/src/Argil/Util/System/File/Exception.php (rev 0)
+++ branches/experimental/src/Argil/Util/System/File/Exception.php 2007-07-14 22:09:35 UTC (rev 544)
@@ -0,0 +1,6 @@
+<?php
+
+class Argil_Util_System_File_Exception extends Exception
+{
+
+}
\ No newline at end of file
Added: branches/experimental/src/Argil/Util/System/File.php
===================================================================
--- branches/experimental/src/Argil/Util/System/File.php (rev 0)
+++ branches/experimental/src/Argil/Util/System/File.php 2007-07-14 22:09:35 UTC (rev 544)
@@ -0,0 +1,45 @@
+<?php
+
+require_once 'Argil/Util/System/Directory.php';
+require_once 'Argil/Util/System/File/Exception.php';
+
+class Argil_Util_System_File
+{
+ private $_file_path = null;
+
+ public function __construct($file_path)
+ {
+ if (!is_file($file_path)) {
+ throw new Argil_Util_System_File_Exception('invalid file provided');
+ }
+
+ $this->_file_path = $file_path;
+ }
+
+ public function __get($key)
+ {
+ switch ($key) {
+ case 'file_name' :
+ return basename($this->_file_path);
+ case 'directory' :
+ return new Argil_Util_System_Directory(dirname($this->_file_path));
+ }
+ }
+
+ public function __set($key, $value)
+ {
+ throw new Argil_Util_System_File_Exception(
+ 'attempted to set read-only file_name property'
+ );
+ }
+
+ public function requireOnce()
+ {
+ require_once $this->_file_path;
+ }
+
+ public function inc()
+ {
+ include $this->_file_path;
+ }
+}
\ No newline at end of file
Modified: branches/experimental/tests/AllTest.php
===================================================================
--- branches/experimental/tests/AllTest.php 2007-07-14 22:05:46 UTC (rev 543)
+++ branches/experimental/tests/AllTest.php 2007-07-14 22:09:35 UTC (rev 544)
@@ -14,6 +14,8 @@
$this->addTestFile('Argil/Util/Annotation/CollectionTest.php');
$this->addTestFile('Argil/Util/Annotation/ParserTest.php');
$this->addTestFile('Argil/Util/Annotation/ValueTest.php');
+ $this->addTestFile('Argil/Util/System/DirectoryTest.php');
+ $this->addTestFile('Argil/Util/System/FileTest.php');
$this->addTestFile('Argil/Util/Template/CamelCapsToUnderscoreTest.php');
}
}
Added: branches/experimental/tests/Argil/Util/System/FileTest.php
===================================================================
--- branches/experimental/tests/Argil/Util/System/FileTest.php (rev 0)
+++ branches/experimental/tests/Argil/Util/System/FileTest.php 2007-07-14 22:09:35 UTC (rev 544)
@@ -0,0 +1,80 @@
+<?php
+
+require_once dirname(__FILE__) . '/../../../config.php';
+require_once 'Argil/Util/System/File.php';
+
+class Argil_Util_System_FileTest extends UnitTestCase
+{
+ public function testThrowsAnExceptionOnInvalidFile()
+ {
+ try {
+ new Argil_Util_System_File(dirname(__FILE__) . '/unknown');
+ $this->fail('exception not caught');
+ } catch (Argil_Util_System_File_Exception $e) {
+ $this->pass('exception caught');
+ $this->assertEqual(
+ 'invalid file provided',
+ $e->getMessage()
+ );
+ }
+
+ new Argil_Util_System_File(__FILE__);
+ $this->pass('properly instantiated');
+ }
+
+ public function testHasReadOnlyPropertyFile_name()
+ {
+ $file = new Argil_Util_System_File(__FILE__);
+ $this->assertEqual(basename(__FILE__), $file->file_name);
+
+ try {
+ $file->file_name = 'new value';
+ $this->fail('exception not caught');
+ } catch (Argil_Util_System_File_Exception $e) {
+ $this->pass('exception caught');
+ $this->assertEqual(
+ 'attempted to set read-only file_name property',
+ $e->getMessage()
+ );
+ }
+ }
+
+ public function testHasReadOnlyDirectoryProperty()
+ {
+ $file = new Argil_Util_System_File(__FILE__);
+ $dir = $file->directory;
+ $this->assertIsA($dir, 'Argil_Util_System_Directory');
+ $this->assertEqual((string)$dir, dirname(__FILE__));
+ }
+
+ public function testRequireOnceLoadsFileOnce()
+ {
+ $file = new Argil_Util_System_File(dirname(__FILE__) . '/../../../support/HelloWorld.php');
+ ob_start();
+ $file->requireOnce();
+ $buf = ob_get_clean();
+
+ $this->assertEqual('Hello World', $buf);
+ unset($buf);
+
+ ob_start();
+ $file->requireOnce();
+ $buf = ob_get_clean();
+ $this->assertEqual('', $buf, "Should be an empty string now that it's been included once");
+ }
+
+ public function testIncAllowsFileToBeLoadedMultipleTimes()
+ {
+ $pattern = '/^Random Number: [12][0-9]{2}/';
+ $file = new Argil_Util_System_File(dirname(__FILE__) . '/../../../support/RandomNumber.php');
+ ob_start();
+ $file->inc();
+ $buffer_one = ob_get_clean();
+ ob_start();
+ $file->inc();
+ $buffer_two = ob_get_clean();
+
+ $this->assertWantedPattern($pattern, $buffer_one);
+ $this->assertWantedPAttern($pattern, $buffer_two);
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tsw...@us...> - 2007-07-14 22:31:54
|
Revision: 547
http://argil.svn.sourceforge.net/argil/?rev=547&view=rev
Author: tswicegood
Date: 2007-07-14 15:31:57 -0700 (Sat, 14 Jul 2007)
Log Message:
-----------
Add in rudimentary support for all tests
Modified Paths:
--------------
branches/experimental/tests/AllTest.php
Added Paths:
-----------
branches/experimental/src/Argil/Controller/
branches/experimental/src/Argil/Controller/Loader.php
branches/experimental/src/Argil/Controller/Locator.php
branches/experimental/tests/Argil/Controller/
branches/experimental/tests/Argil/Controller/LoaderTest.php
branches/experimental/tests/Argil/Controller/LocatorTest.php
branches/experimental/tests/support/controllers/
branches/experimental/tests/support/controllers/PersonController.php
Added: branches/experimental/src/Argil/Controller/Loader.php
===================================================================
--- branches/experimental/src/Argil/Controller/Loader.php (rev 0)
+++ branches/experimental/src/Argil/Controller/Loader.php 2007-07-14 22:31:57 UTC (rev 547)
@@ -0,0 +1,26 @@
+<?php
+
+require_once 'Argil/Controller/Locator.php';
+require_once 'Argil/Util/System/Directory.php';
+
+class Argil_Controller_Loader
+{
+ private $_locator = null;
+
+ public function __construct(Argil_Util_System_Directory $directory)
+ {
+ $this->_locator = new Argil_Controller_Locator($directory);
+ }
+
+ public function load($name)
+ {
+ $controller_name = $name . 'Controller';
+ if (!class_exists($controller_name)) {
+ $file = $this->_locator->locate($name);
+ $file->requireOnce();
+ }
+
+ $controller = new $controller_name();
+ return $controller;
+ }
+}
\ No newline at end of file
Added: branches/experimental/src/Argil/Controller/Locator.php
===================================================================
--- branches/experimental/src/Argil/Controller/Locator.php (rev 0)
+++ branches/experimental/src/Argil/Controller/Locator.php 2007-07-14 22:31:57 UTC (rev 547)
@@ -0,0 +1,21 @@
+<?php
+
+require_once 'Argil/Util/System/Directory.php';
+require_once 'Argil/Util/System/File.php';
+
+class Argil_Controller_Locator
+{
+ private $_path = null;
+
+ public function __construct(Argil_Util_System_Directory $path)
+ {
+ $this->_path = $path;
+ }
+
+ public function locate($name)
+ {
+ $expected_path = (string)$this->_path . '/' . $name . 'Controller.php';
+ $file = new Argil_Util_System_File($expected_path);
+ return $file;
+ }
+}
\ No newline at end of file
Modified: branches/experimental/tests/AllTest.php
===================================================================
--- branches/experimental/tests/AllTest.php 2007-07-14 22:12:03 UTC (rev 546)
+++ branches/experimental/tests/AllTest.php 2007-07-14 22:31:57 UTC (rev 547)
@@ -4,6 +4,8 @@
{
public function __construct()
{
+ $this->addTestFile('Argil/Controller/LoaderTest.php');
+ $this->addTestFile('Argil/Controller/LocatorTest.php');
$this->addTestFile('Argil/Model/ContainerTest.php');
$this->addTestFile('Argil/Reflection/ObjectTest.php');
$this->addTestFile('Argil/Reflection/PropertyListTest.php');
Added: branches/experimental/tests/Argil/Controller/LoaderTest.php
===================================================================
--- branches/experimental/tests/Argil/Controller/LoaderTest.php (rev 0)
+++ branches/experimental/tests/Argil/Controller/LoaderTest.php 2007-07-14 22:31:57 UTC (rev 547)
@@ -0,0 +1,20 @@
+<?php
+
+require_once dirname(__FILE__) . '/../../config.php';
+require_once 'Argil/Controller/Loader.php';
+
+class Argil_Controller_LoaderTest extends UnitTestCase
+{
+ public function testLoadsAndReturnsANewController()
+ {
+ $directory = new Argil_Util_System_Directory(
+ dirname(__FILE__) . '/../../support/controllers'
+ );
+
+ $loader = new Argil_Controller_Loader($directory);
+ $controller = $loader->load('Person');
+
+ $this->assertIsA($controller, 'PersonController');
+
+ }
+}
\ No newline at end of file
Added: branches/experimental/tests/Argil/Controller/LocatorTest.php
===================================================================
--- branches/experimental/tests/Argil/Controller/LocatorTest.php (rev 0)
+++ branches/experimental/tests/Argil/Controller/LocatorTest.php 2007-07-14 22:31:57 UTC (rev 547)
@@ -0,0 +1,26 @@
+<?php
+
+require_once dirname(__FILE__) . '/../../config.php';
+require_once 'Argil/Controller/Locator.php';
+
+class Argil_Controller_LocatorTest extends UnitTestCase
+{
+ public function testRequiresADirectoryObjectAtConstruct()
+ {
+ $reflection = new ReflectionClass('Argil_Controller_Locator');
+ $constructor = $reflection->getConstructor();
+ $firstParam = array_shift($constructor->getParameters());
+ $this->assertFalse($firstParam->isOptional());
+ $this->assertEqual('Argil_Util_System_Directory', $firstParam->getClass()->getName());
+ }
+
+ public function testLocateReturnsAValidFileForInclusion()
+ {
+ $directory = new Argil_Util_System_Directory(dirname(__FILE__) . '/../../support/controllers');
+ $locator = new Argil_Controller_Locator($directory);
+ $file = $locator->locate('Person');
+ $this->assertIsA($file, 'Argil_Util_System_File');
+ $this->assertEqual('PersonController.php', $file->file_name);
+ $this->assertEqual($directory, $file->directory);
+ }
+}
\ No newline at end of file
Added: branches/experimental/tests/support/controllers/PersonController.php
===================================================================
--- branches/experimental/tests/support/controllers/PersonController.php (rev 0)
+++ branches/experimental/tests/support/controllers/PersonController.php 2007-07-14 22:31:57 UTC (rev 547)
@@ -0,0 +1,9 @@
+<?php
+
+class PersonController
+{
+ public function __construct()
+ {
+
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tsw...@us...> - 2007-07-15 01:07:37
|
Revision: 548
http://argil.svn.sourceforge.net/argil/?rev=548&view=rev
Author: tswicegood
Date: 2007-07-14 18:07:39 -0700 (Sat, 14 Jul 2007)
Log Message:
-----------
Remove annotation code from Argil - now uses Domain51_Tool_Annotation
Modified Paths:
--------------
branches/experimental/src/Argil/Reflection/Object.php
branches/experimental/tests/AllTest.php
branches/experimental/tests/config.php
Removed Paths:
-------------
branches/experimental/src/Argil/Util/Annotation/
branches/experimental/tests/Argil/Util/Annotation/
Modified: branches/experimental/src/Argil/Reflection/Object.php
===================================================================
--- branches/experimental/src/Argil/Reflection/Object.php 2007-07-14 22:31:57 UTC (rev 547)
+++ branches/experimental/src/Argil/Reflection/Object.php 2007-07-15 01:07:39 UTC (rev 548)
@@ -1,7 +1,7 @@
<?php
require_once 'Argil/Reflection/Property.php';
require_once 'Argil/Reflection/PropertyList.php';
-require_once 'Argil/Util/Annotation/Parser.php';
+require_once 'Domain51/Tool/Annotation/Parser.php';
class Argil_Reflection_Object
{
@@ -29,7 +29,7 @@
public function getTable()
{
- $parser = new Argil_Util_Annotation_Parser();
+ $parser = new Domain51_Tool_Annotation_Parser();
$collection = $parser->parse($this->_decorated->getDocComment());
if (!$collection->has('table')) {
@@ -41,7 +41,7 @@
public function getPrimaryKey()
{
- $parser = new Argil_Util_Annotation_Parser();
+ $parser = new Domain51_Tool_Annotation_Parser();
$collection = $parser->parse($this->_decorated->getDocComment());
if (!$collection->has('primaryKey')) {
Modified: branches/experimental/tests/AllTest.php
===================================================================
--- branches/experimental/tests/AllTest.php 2007-07-14 22:31:57 UTC (rev 547)
+++ branches/experimental/tests/AllTest.php 2007-07-15 01:07:39 UTC (rev 548)
@@ -13,9 +13,6 @@
$this->addTestFile('Argil/RouteTest.php');
$this->addTestFile('Argil/Specification/LengthTest.php');
$this->addTestFile('Argil/Specification/StringTest.php');
- $this->addTestFile('Argil/Util/Annotation/CollectionTest.php');
- $this->addTestFile('Argil/Util/Annotation/ParserTest.php');
- $this->addTestFile('Argil/Util/Annotation/ValueTest.php');
$this->addTestFile('Argil/Util/System/DirectoryTest.php');
$this->addTestFile('Argil/Util/System/FileTest.php');
$this->addTestFile('Argil/Util/Template/CamelCapsToUnderscoreTest.php');
Modified: branches/experimental/tests/config.php
===================================================================
--- branches/experimental/tests/config.php 2007-07-14 22:31:57 UTC (rev 547)
+++ branches/experimental/tests/config.php 2007-07-15 01:07:39 UTC (rev 548)
@@ -2,7 +2,9 @@
require_once 'simpletest/unit_tester.php';
require_once 'simpletest/mock_objects.php';
require_once 'simpletest/autorun.php';
-set_include_path(dirname(__FILE__) . PATH_SEPARATOR . dirname(__FILE__) . '/../src' . PATH_SEPARATOR . get_include_path());
+set_include_path(
+ dirname(__FILE__) . PATH_SEPARATOR .
+ dirname(__FILE__) . '/../src' . PATH_SEPARATOR .
+ get_include_path()
+);
-require_once 'Argil/Util/Annotation/Value.php';
-Mock::generate('Argil_Util_Annotation_Value');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|