├── .gitignore
├── test
├── templates
│ ├── affected.json.php
│ ├── coverage.json.php
│ ├── profiler.json.php
│ ├── stats.json.php
│ ├── affected.txt.php
│ ├── skips.txt.php
│ ├── profiler.html.php
│ ├── profiler.txt.php
│ ├── fail.html.php
│ ├── affected.html.php
│ ├── exception.html.php
│ ├── complexity.txt.php
│ ├── complexity.json.php
│ ├── result.txt.php
│ ├── complexity.html.php
│ ├── menu.html.php
│ ├── errors.txt.php
│ ├── stats.html.php
│ └── coverage.txt.php
└── Filter.php
├── tests
├── mocks
│ ├── template
│ │ ├── view
│ │ │ └── adapters
│ │ │ │ ├── testFile.html.php
│ │ │ │ ├── testTypeFile.view-integration-test.php
│ │ │ │ ├── testLayoutFile.html.php
│ │ │ │ └── TestRenderer.php
│ │ ├── MockView.php
│ │ ├── MockRenderer.php
│ │ ├── helper
│ │ │ ├── MockFormPostInfo.php
│ │ │ ├── MockFormRenderer.php
│ │ │ └── MockFormPost.php
│ │ └── MockHelper.php
│ ├── data
│ │ ├── MockConnections.php
│ │ ├── MockComments.php
│ │ ├── MockPosts.php
│ │ ├── MockTag.php
│ │ ├── MockBadConnection.php
│ │ ├── MockCouchModel.php
│ │ ├── MockTagging.php
│ │ ├── MockPostObject.php
│ │ ├── MockCollection.php
│ │ ├── source
│ │ │ ├── database
│ │ │ │ └── adapter
│ │ │ │ │ ├── MockMySql.php
│ │ │ │ │ ├── MockSqlite3.php
│ │ │ │ │ └── MockPostgreSql.php
│ │ │ ├── MockMongoPost.php
│ │ │ ├── http
│ │ │ │ └── adapter
│ │ │ │ │ └── MockCouchPost.php
│ │ │ ├── MockHttpModel.php
│ │ │ ├── MockMongoSource.php
│ │ │ ├── mongo_db
│ │ │ │ └── MockResult.php
│ │ │ └── MockMongoConnection.php
│ │ ├── MockDocumentSource.php
│ │ ├── model
│ │ │ ├── MockDatabaseTag.php
│ │ │ ├── MockDatabaseTagging.php
│ │ │ ├── MockTag.php
│ │ │ ├── MockDatabaseComment.php
│ │ │ ├── MockQueryComment.php
│ │ │ ├── MockDatabasePostRevision.php
│ │ │ ├── MockQueryPost.php
│ │ │ ├── MockDatabasePost.php
│ │ │ ├── MockGallery.php
│ │ │ ├── MockImageTag.php
│ │ │ ├── MockImage.php
│ │ │ ├── mock_database
│ │ │ │ └── MockResult.php
│ │ │ ├── MockDocumentMultipleKey.php
│ │ │ ├── MockDocumentPost.php
│ │ │ └── MockDocumentSource.php
│ │ ├── MockPost.php
│ │ ├── MockCreator.php
│ │ ├── MockSubProduct.php
│ │ ├── MockModel.php
│ │ ├── MockModelCompositePk.php
│ │ ├── collection
│ │ │ ├── MockRecordSet.php
│ │ │ └── MockMultiKeyRecordSet.php
│ │ ├── MockPostForValidates.php
│ │ ├── MockProduct.php
│ │ └── MockComment.php
│ ├── test
│ │ ├── MockNonLi3StdClass.php
│ │ ├── MockStdStaticClass.php
│ │ ├── cases
│ │ │ ├── MockTest.php
│ │ │ ├── MockErrorHandlingTest.php
│ │ │ ├── MockSkipThrowsExceptionTest.php
│ │ │ ├── MockSetUpThrowsExceptionTest.php
│ │ │ └── MockTearDownThrowsExceptionTest.php
│ │ ├── MockFilterClassTest.php
│ │ ├── MockFilterClass.php
│ │ ├── MockIntegrationTest.php
│ │ ├── MockStdClass.php
│ │ └── MockUnitTest.php
│ ├── analysis
│ │ ├── MockEmptyClass.php
│ │ ├── MockInspector.php
│ │ └── MockLoggerAdapter.php
│ ├── action
│ │ ├── MockControllerRequest.php
│ │ ├── MockControllerResponse.php
│ │ ├── MockRequestType.php
│ │ ├── MockMediaClass.php
│ │ ├── MockRenderAltController.php
│ │ ├── MockResponse.php
│ │ ├── MockDispatcher.php
│ │ └── MockPostsController.php
│ ├── core
│ │ ├── MockInitMethod.php
│ │ ├── MockObjectForParents.php
│ │ ├── MockAdapter.php
│ │ ├── MockStrategy.php
│ │ ├── MockStaticFilteringExtended.php
│ │ ├── MockErrorHandler.php
│ │ ├── MockInstantiator.php
│ │ ├── MockStaticInstantiator.php
│ │ ├── MockExposed.php
│ │ ├── MockRequest.php
│ │ ├── MockCallable.php
│ │ ├── MockObjectConfiguration.php
│ │ ├── MockMethodFiltering.php
│ │ └── MockStaticMethodFiltering.php
│ ├── g11n
│ │ ├── catalog
│ │ │ ├── MockAdapter.php
│ │ │ └── adapter
│ │ │ │ └── MockGettext.php
│ │ └── multibyte
│ │ │ └── adapter
│ │ │ └── MockAdapter.php
│ ├── util
│ │ ├── MockCollectionStringCast.php
│ │ ├── MockFilters.php
│ │ ├── MockCollectionMarker.php
│ │ ├── MockStringObject.php
│ │ └── MockCollectionObject.php
│ ├── console
│ │ ├── MockDispatcherRequest.php
│ │ ├── command
│ │ │ ├── MockCreate.php
│ │ │ └── MockCommandHelp.php
│ │ ├── MockDispatcherCommand.php
│ │ ├── MockResponse.php
│ │ └── MockCommand.php
│ ├── net
│ │ └── http
│ │ │ └── Template.php
│ ├── security
│ │ └── auth
│ │ │ └── adapter
│ │ │ ├── MockHttp.php
│ │ │ └── MockAuthAdapter.php
│ └── storage
│ │ ├── session
│ │ ├── adapter
│ │ │ ├── SessionStorageConditional.php
│ │ │ └── MockPhp.php
│ │ └── strategy
│ │ │ ├── MockEncrypt.php
│ │ │ └── MockCookieSession.php
│ │ └── cache
│ │ └── strategy
│ │ ├── MockSerializer.php
│ │ └── MockConfigurizer.php
├── resources
│ └── utf8_decoder_stress_test.txt
├── cases
│ ├── analysis
│ │ ├── DebuggerTest.php
│ │ └── logger
│ │ │ └── adapter
│ │ │ ├── SyslogTest.php
│ │ │ ├── FileTest.php
│ │ │ └── CacheTest.php
│ ├── test
│ │ ├── ControllerTest.php
│ │ └── IntegrationTest.php
│ ├── storage
│ │ └── cache
│ │ │ └── strategy
│ │ │ ├── JsonTest.php
│ │ │ ├── Base64Test.php
│ │ │ └── SerializerTest.php
│ ├── net
│ │ └── SocketTest.php
│ ├── template
│ │ └── view
│ │ │ └── adapter
│ │ │ └── SimpleTest.php
│ ├── data
│ │ ├── SchemaTest.php
│ │ ├── source
│ │ │ └── mongo_db
│ │ │ │ └── SchemaTest.php
│ │ └── SourceTest.php
│ ├── g11n
│ │ └── catalog
│ │ │ └── adapter
│ │ │ └── MemoryTest.php
│ ├── console
│ │ └── command
│ │ │ └── create
│ │ │ └── ModelTest.php
│ └── security
│ │ └── validation
│ │ └── FormSignatureTest.php
├── fixture
│ └── model
│ │ └── gallery
│ │ ├── Comments.php
│ │ ├── Galleries.php
│ │ ├── ImagesTags.php
│ │ ├── Tags.php
│ │ ├── Images.php
│ │ ├── export
│ │ ├── testSaveHabtmWithFormCompatibleData.php
│ │ ├── testOneToMany.php
│ │ ├── testManyToOne.php
│ │ └── testSaveNested.php
│ │ ├── TagsFixture.php
│ │ ├── ImagesTagsFixture.php
│ │ ├── GalleriesFixture.php
│ │ └── ImagesFixture.php
├── ci
│ └── config
│ │ └── libraries.php
└── integration
│ ├── analysis
│ └── LoggerTest.php
│ ├── net
│ └── http
│ │ └── ServiceTest.php
│ ├── g11n
│ ├── CatalogInflectorTest.php
│ └── CatalogValidatorTest.php
│ └── data
│ ├── Base.php
│ └── DocumentTest.php
├── action
├── readme.md
└── DispatchException.php
├── console
├── command
│ ├── create
│ │ ├── template
│ │ │ ├── app.phar.gz
│ │ │ ├── mock.txt.php
│ │ │ ├── plugin.phar.gz
│ │ │ ├── model.txt.php
│ │ │ ├── test-app-replacements.phar.gz
│ │ │ ├── test.txt.php
│ │ │ └── controller.txt.php
│ │ ├── Model.php
│ │ ├── Mock.php
│ │ └── Controller.php
│ └── G11n.php
├── li3.bat
├── li3
└── Router.php
├── g11n
├── resources
│ └── php
│ │ ├── de_DE
│ │ └── validation
│ │ │ └── default.php
│ │ ├── it_IT
│ │ └── validation
│ │ │ └── default.php
│ │ ├── nl_NL
│ │ └── validation
│ │ │ └── default.php
│ │ ├── de_BE
│ │ └── validation
│ │ │ └── default.php
│ │ ├── fr_BE
│ │ └── validation
│ │ │ └── default.php
│ │ ├── nl_BE
│ │ └── validation
│ │ │ └── default.php
│ │ ├── da_DK
│ │ └── validation
│ │ │ └── default.php
│ │ ├── en_GB
│ │ └── validation
│ │ │ └── default.php
│ │ ├── en_CA
│ │ └── validation
│ │ │ └── default.php
│ │ ├── fr_CA
│ │ └── validation
│ │ │ └── default.php
│ │ ├── en_US
│ │ └── validation
│ │ │ └── default.php
│ │ ├── de
│ │ └── message
│ │ │ └── default.php
│ │ ├── en
│ │ └── message
│ │ │ └── default.php
│ │ └── fr
│ │ └── message
│ │ └── default.php
└── catalog
│ └── adapter
│ └── Memory.php
├── core
├── ConfigException.php
├── ClassNotFoundException.php
└── NetworkException.php
├── data
├── model
│ └── QueryException.php
└── source
│ ├── mongo_db
│ ├── Result.php
│ └── Schema.php
│ ├── database
│ └── adapter
│ │ └── pdo
│ │ └── Result.php
│ └── Mock.php
├── net
└── http
│ ├── MediaException.php
│ ├── RoutingException.php
│ └── ClientMediaException.php
├── storage
├── session
│ └── strategy
│ │ └── MissingSignatureException.php
└── cache
│ └── strategy
│ ├── Serializer.php
│ ├── Base64.php
│ └── Json.php
├── template
├── TemplateException.php
└── view
│ └── adapter
│ └── Simple.php
├── composer.json
├── LICENSE.txt
├── CONTRIBUTING.md
└── readme.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS X
2 | .DS_Store
3 |
4 | # Vim
5 | .*.sw[a-z]
6 |
--------------------------------------------------------------------------------
/test/templates/affected.json.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/templates/coverage.json.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/templates/profiler.json.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/template/view/adapters/testFile.html.php:
--------------------------------------------------------------------------------
1 | This is a test.
--------------------------------------------------------------------------------
/test/templates/stats.json.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/template/view/adapters/testTypeFile.view-integration-test.php:
--------------------------------------------------------------------------------
1 | This is a type test.
--------------------------------------------------------------------------------
/tests/mocks/template/view/adapters/testLayoutFile.html.php:
--------------------------------------------------------------------------------
1 | Layout top.
2 | =$this->content(); ?>
3 | Layout bottom.
--------------------------------------------------------------------------------
/action/readme.md:
--------------------------------------------------------------------------------
1 | The `action` namespace relies on `lithium\http`, and includes classes required to route and dispatch HTTP requests.
--------------------------------------------------------------------------------
/console/command/create/template/app.phar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jails/lithium/master/console/command/create/template/app.phar.gz
--------------------------------------------------------------------------------
/console/command/create/template/mock.txt.php:
--------------------------------------------------------------------------------
1 | namespace {:namespace};
2 |
3 | class {:class} extends {:parent} {
4 |
5 | {:methods}
6 | }
--------------------------------------------------------------------------------
/console/command/create/template/plugin.phar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jails/lithium/master/console/command/create/template/plugin.phar.gz
--------------------------------------------------------------------------------
/tests/resources/utf8_decoder_stress_test.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jails/lithium/master/tests/resources/utf8_decoder_stress_test.txt
--------------------------------------------------------------------------------
/console/command/create/template/model.txt.php:
--------------------------------------------------------------------------------
1 | namespace {:namespace};
2 |
3 | class {:class} extends \lithium\data\Model {
4 |
5 | public $validates = array();
6 | }
--------------------------------------------------------------------------------
/console/command/create/template/test-app-replacements.phar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jails/lithium/master/console/command/create/template/test-app-replacements.phar.gz
--------------------------------------------------------------------------------
/test/templates/affected.txt.php:
--------------------------------------------------------------------------------
1 | {:heading}Affected Tests{:end}
2 | $test) {
4 | if ($test) {
5 | echo "{$test}\n";
6 | }
7 | }
8 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockConnections.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/console/command/create/template/test.txt.php:
--------------------------------------------------------------------------------
1 | namespace {:namespace};
2 |
3 | use {:use};
4 |
5 | class {:class} extends \lithium\test\Unit {
6 |
7 | public function setUp() {}
8 |
9 | public function tearDown() {}
10 |
11 | {:methods}
12 | }
--------------------------------------------------------------------------------
/console/li3.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | rem
3 | rem Lithium: the most rad php framework
4 | rem
5 | rem @copyright Copyright 2014, Union of RAD (http://union-of-rad.org)
6 | rem @license http://opensource.org/licenses/bsd-license.php The BSD License
7 | rem
8 | php -f "%~dp0lithium.php" %*
9 |
--------------------------------------------------------------------------------
/tests/mocks/test/MockNonLi3StdClass.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/test/MockStdStaticClass.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/templates/skips.txt.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/console/li3:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # Lithium: the most rad php framework
4 | #
5 | # @copyright Copyright 2014, Union of RAD (http://union-of-rad.org)
6 | # @license http://opensource.org/licenses/bsd-license.php The BSD License
7 | #
8 | SELF=$0; test -L "$0" && SELF=$(readlink -n $0)
9 | php -f "$(dirname "$SELF")"/lithium.php -- "$@"
10 |
--------------------------------------------------------------------------------
/test/templates/profiler.html.php:
--------------------------------------------------------------------------------
1 |
Benchmarks
2 |
3 |
4 | $result): ?>
5 |
6 | |
7 | |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test/templates/profiler.txt.php:
--------------------------------------------------------------------------------
1 | {:heading}Benchmarks{:end}
2 | $v) ? $l : $v;
6 | });
7 | foreach ($data['totals'] as $title => $result) {
8 | printf("%-{$width}s %s\n", $title, $result['formatter']($result['value']));
9 | }
10 |
11 | ?>
--------------------------------------------------------------------------------
/tests/mocks/analysis/MockEmptyClass.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/templates/fail.html.php:
--------------------------------------------------------------------------------
1 |
2 | Assertion '' failed in
3 | ::()
4 | on line :
5 |
6 |
7 |
--------------------------------------------------------------------------------
/tests/cases/analysis/DebuggerTest.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/templates/affected.html.php:
--------------------------------------------------------------------------------
1 | Affected Tests
2 |
3 |
4 | $test): ?>
5 |
6 | -
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/g11n/resources/php/de_DE/validation/default.php:
--------------------------------------------------------------------------------
1 | '/^[0-9]{5}$/i'
14 | );
15 |
16 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/it_IT/validation/default.php:
--------------------------------------------------------------------------------
1 | '/^[0-9]{5}$/i'
14 | );
15 |
16 | ?>
--------------------------------------------------------------------------------
/tests/mocks/action/MockControllerRequest.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/g11n/resources/php/nl_NL/validation/default.php:
--------------------------------------------------------------------------------
1 | '/\\A\\b[0-9]{9}\\b\\z/i'
14 | );
15 |
16 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/de_BE/validation/default.php:
--------------------------------------------------------------------------------
1 | '/^[1-9]{1}[0-9]{3}$/i'
14 | );
15 |
16 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/fr_BE/validation/default.php:
--------------------------------------------------------------------------------
1 | '/^[1-9]{1}[0-9]{3}$/i'
14 | );
15 |
16 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/nl_BE/validation/default.php:
--------------------------------------------------------------------------------
1 | '/^[1-9]{1}[0-9]{3}$/i'
14 | );
15 |
16 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/da_DK/validation/default.php:
--------------------------------------------------------------------------------
1 | '/\\A\\b[0-9]{6}-[0-9]{4}\\b\\z/i'
14 | );
15 |
16 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockComments.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/data/MockPosts.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/data/MockTag.php:
--------------------------------------------------------------------------------
1 | false);
14 | }
15 |
16 | ?>
--------------------------------------------------------------------------------
/test/templates/exception.html.php:
--------------------------------------------------------------------------------
1 |
2 | Exception thrown in
3 | on line
4 |
5 |
6 | Trace
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/templates/complexity.txt.php:
--------------------------------------------------------------------------------
1 | {:heading}Cyclomatic Complexity{:end}
2 | $count) {
4 | if ($count <= 7) {
5 | continue;
6 | }
7 | echo "Worst Offender\n\t{$method} - {$count}\n";
8 | }
9 | ?>
10 | {:heading}Class Averages{:end}
11 | $count) {
13 | echo "\t{$class} - ";
14 | echo round($count, 2) . "\n";
15 | }
16 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/Comments.php:
--------------------------------------------------------------------------------
1 | 'test');
14 | }
15 |
16 | ?>
--------------------------------------------------------------------------------
/test/templates/complexity.json.php:
--------------------------------------------------------------------------------
1 | $count) {
7 | if ($count <= 7) {
8 | continue;
9 | }
10 | $worstOffender = compact('method', 'count');
11 | }
12 | foreach (array_slice($data['class'], 0, 10) as $class => $count) {
13 | $averages[$class] = $count;
14 | }
15 |
16 | echo json_encode(compact('worstOffender', 'averages'));
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockBadConnection.php:
--------------------------------------------------------------------------------
1 | 'bad_connection');
14 | }
15 |
16 | ?>
--------------------------------------------------------------------------------
/tests/mocks/test/cases/MockTest.php:
--------------------------------------------------------------------------------
1 | assertTrue(true);
15 | }
16 | }
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/mocks/template/MockView.php:
--------------------------------------------------------------------------------
1 | _config['renderer'];
15 | }
16 | }
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/mocks/core/MockInitMethod.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/core/MockObjectForParents.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/template/MockRenderer.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/test/cases/MockErrorHandlingTest.php:
--------------------------------------------------------------------------------
1 | _arrayPermute();
15 | }
16 | }
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/Galleries.php:
--------------------------------------------------------------------------------
1 | 'test');
16 | }
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/mocks/core/MockAdapter.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/g11n/catalog/MockAdapter.php:
--------------------------------------------------------------------------------
1 | _merge($data, $item);
15 | }
16 | }
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/mocks/analysis/MockInspector.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/core/MockStrategy.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/cases/test/ControllerTest.php:
--------------------------------------------------------------------------------
1 | controller = new Controller();
17 | }
18 | }
19 |
20 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/ImagesTags.php:
--------------------------------------------------------------------------------
1 | 'test');
16 | }
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/mocks/util/MockCollectionStringCast.php:
--------------------------------------------------------------------------------
1 | 2, 2 => 3);
13 |
14 | public function __toString() {
15 | return json_encode($this->_data);
16 | }
17 | }
18 |
19 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockCouchModel.php:
--------------------------------------------------------------------------------
1 | false);
14 |
15 | protected $_schema = array(
16 | 'someKey' => array()
17 | );
18 | }
19 |
20 | ?>
--------------------------------------------------------------------------------
/core/ConfigException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/console/MockDispatcherRequest.php:
--------------------------------------------------------------------------------
1 | '\lithium\tests\mocks\console\MockDispatcherCommand'
15 | );
16 | }
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/mocks/core/MockStaticFilteringExtended.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/data/MockTagging.php:
--------------------------------------------------------------------------------
1 | false,
15 | 'source' => 'posts_tags', 'key' => array('post_id', 'tag_id')
16 | );
17 | }
18 |
19 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/en_GB/validation/default.php:
--------------------------------------------------------------------------------
1 | '/\\A\\b[A-Z]{1,2}[0-9][A-Z0-9]? [0-9][ABD-HJLNP-UW-Z]{2}\\b\\z/i'
16 | );
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/Tags.php:
--------------------------------------------------------------------------------
1 | array('via' => 'ImagesTags'));
16 | }
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/mocks/action/MockControllerResponse.php:
--------------------------------------------------------------------------------
1 | hasRendered = true;
17 | }
18 | }
19 |
20 | ?>
--------------------------------------------------------------------------------
/tests/mocks/analysis/MockLoggerAdapter.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/test/cases/MockSkipThrowsExceptionTest.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/g11n/resources/php/en_CA/validation/default.php:
--------------------------------------------------------------------------------
1 | '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/',
14 | 'postalCode' => '/\\A\\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z] [0-9][A-Z][0-9]\\b\\z/i'
15 | );
16 |
17 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/fr_CA/validation/default.php:
--------------------------------------------------------------------------------
1 | '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/',
14 | 'postalCode' => '/\\A\\b[ABCEGHJKLMNPRSTVXY][0-9][A-Z] [0-9][A-Z][0-9]\\b\\z/i'
15 | );
16 |
17 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockPostObject.php:
--------------------------------------------------------------------------------
1 | $value) {
19 | $this->$key = $value;
20 | }
21 | }
22 | }
23 |
24 | ?>
--------------------------------------------------------------------------------
/tests/mocks/net/http/Template.php:
--------------------------------------------------------------------------------
1 | headers('Custom', 'Value');
15 | }
16 |
17 | public function render() {}
18 | }
19 |
20 | ?>
--------------------------------------------------------------------------------
/tests/mocks/action/MockRequestType.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/security/auth/adapter/MockHttp.php:
--------------------------------------------------------------------------------
1 | headers[] = $string;
17 | }
18 | }
19 |
20 | ?>
--------------------------------------------------------------------------------
/tests/mocks/storage/session/adapter/SessionStorageConditional.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/core/MockErrorHandler.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/util/MockFilters.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/model/QueryException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/core/ClassNotFoundException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/net/http/MediaException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/net/http/RoutingException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/data/MockCollection.php:
--------------------------------------------------------------------------------
1 | _data[$offset] = $data;
15 | return $data;
16 | }
17 | }
18 |
19 | ?>
--------------------------------------------------------------------------------
/tests/mocks/test/MockFilterClassTest.php:
--------------------------------------------------------------------------------
1 | assertTrue(true);
19 | }
20 | }
21 |
22 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/en_US/validation/default.php:
--------------------------------------------------------------------------------
1 | '/^(?:\+?1)?[-. ]?\\(?[2-9][0-8][0-9]\\)?[-. ]?[2-9][0-9]{2}[-. ]?[0-9]{4}$/',
14 | 'postalCode' => '/\\A\\b[0-9]{5}(?:-[0-9]{4})?\\b\\z/i',
15 | 'ssn' => '/\\A\\b[0-9]{3}-[0-9]{2}-[0-9]{4}\\b\\z/i'
16 | );
17 |
18 | ?>
--------------------------------------------------------------------------------
/tests/mocks/action/MockMediaClass.php:
--------------------------------------------------------------------------------
1 | options = $options;
15 | $response->data = $data;
16 | return $response;
17 | }
18 | }
19 |
20 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/source/database/adapter/MockMySql.php:
--------------------------------------------------------------------------------
1 | {$var};
15 | }
16 |
17 | protected function _execute($sql) {
18 | return $sql;
19 | }
20 | }
21 |
22 | ?>
--------------------------------------------------------------------------------
/tests/mocks/action/MockRenderAltController.php:
--------------------------------------------------------------------------------
1 | array('foo' => 'bar'),
14 | 'layout' => 'alternate'
15 | );
16 |
17 | public function access($var) {
18 | return $this->{$var};
19 | }
20 | }
21 |
22 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/source/database/adapter/MockSqlite3.php:
--------------------------------------------------------------------------------
1 | {$var};
15 | }
16 |
17 | protected function _execute($sql) {
18 | return $sql;
19 | }
20 | }
21 |
22 | ?>
--------------------------------------------------------------------------------
/tests/mocks/core/MockInstantiator.php:
--------------------------------------------------------------------------------
1 | 'lithium\tests\mocks\core\MockRequest');
14 |
15 | public function instance($name, array $config = array()) {
16 | return $this->_instance($name, $config);
17 | }
18 | }
19 |
20 | ?>
--------------------------------------------------------------------------------
/tests/mocks/util/MockCollectionMarker.php:
--------------------------------------------------------------------------------
1 | marker = true;
19 | return true;
20 | }
21 |
22 | public function mapArray() {
23 | return array('foo');
24 | }
25 | }
26 |
27 | ?>
--------------------------------------------------------------------------------
/net/http/ClientMediaException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/data/source/database/adapter/MockPostgreSql.php:
--------------------------------------------------------------------------------
1 | {$var};
15 | }
16 |
17 | protected function _execute($sql) {
18 | return $sql;
19 | }
20 | }
21 |
22 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/de/message/default.php:
--------------------------------------------------------------------------------
1 | 2,
18 | 'pluralRule' => function ($n) { return $n != 1 ? 1 : 0; }
19 | );
20 |
21 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/en/message/default.php:
--------------------------------------------------------------------------------
1 | 2,
18 | 'pluralRule' => function ($n) { return $n != 1 ? 1 : 0; }
19 | );
20 |
21 | ?>
--------------------------------------------------------------------------------
/g11n/resources/php/fr/message/default.php:
--------------------------------------------------------------------------------
1 | 2,
18 | 'pluralRule' => function ($n) { return $n > 1 ? 1 : 0; }
19 | );
20 |
21 | ?>
--------------------------------------------------------------------------------
/tests/mocks/test/MockFilterClass.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/util/MockStringObject.php:
--------------------------------------------------------------------------------
1 | message;
20 | }
21 | }
22 |
23 | ?>
--------------------------------------------------------------------------------
/core/NetworkException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/storage/session/strategy/MissingSignatureException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/test/cases/MockSetUpThrowsExceptionTest.php:
--------------------------------------------------------------------------------
1 | assert(true);
21 | }
22 |
23 | }
24 |
25 | ?>
--------------------------------------------------------------------------------
/test/templates/result.txt.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/test/cases/MockTearDownThrowsExceptionTest.php:
--------------------------------------------------------------------------------
1 | assert(true);
17 | }
18 |
19 | public function tearDown() {
20 | throw new Exception('tearDown throws exception');
21 | }
22 | }
23 |
24 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/Images.php:
--------------------------------------------------------------------------------
1 | array('via' => 'ImagesTags'));
18 |
19 | protected $_meta = array('connection' => 'test');
20 | }
21 |
22 | ?>
--------------------------------------------------------------------------------
/tests/mocks/console/command/MockCreate.php:
--------------------------------------------------------------------------------
1 | 'lithium\tests\mocks\console\MockResponse'
15 | );
16 |
17 | public function save($template, $params = array()) {
18 | return $this->_save($template, $params);
19 | }
20 | }
21 |
22 | ?>
--------------------------------------------------------------------------------
/tests/mocks/storage/session/strategy/MockEncrypt.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/test/MockIntegrationTest.php:
--------------------------------------------------------------------------------
1 | assertTrue(true);
15 | }
16 |
17 | public function testFail() {
18 | $this->assertTrue(false);
19 | }
20 |
21 | public function testAnotherPass() {
22 | $this->assertTrue(true);
23 | }
24 | }
25 |
26 | ?>
--------------------------------------------------------------------------------
/template/TemplateException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "unionofrad/lithium",
3 | "description": "The core library of the Lithium PHP framework",
4 | "keywords": ["lithium", "framework"],
5 | "homepage": "http://li3.me",
6 | "license": "BSD-3-Clause",
7 | "authors": [
8 | {
9 | "name": "Union of RAD",
10 | "homepage": "http://union-of-rad.org"
11 | },
12 | {
13 | "name": "The Lithium Community",
14 | "homepage": "http://github.com/UnionOfRAD/lithium/graphs/contributors"
15 | }
16 | ],
17 | "require": {
18 | "php": ">=5.3.6"
19 | },
20 | "autoload": {
21 | "psr-0": { "lithium": "" }
22 | },
23 | "target-dir": "lithium",
24 | "bin" : ["console/li3"]
25 | }
26 |
--------------------------------------------------------------------------------
/tests/mocks/data/MockDocumentSource.php:
--------------------------------------------------------------------------------
1 | 'lithium\data\entity\Document',
15 | 'set' => 'lithium\data\collection\DocumentSet',
16 | 'relationship' => 'lithium\data\model\Relationship',
17 | 'schema' => 'lithium\data\DocumentSchema'
18 | );
19 | }
20 |
21 | ?>
--------------------------------------------------------------------------------
/tests/mocks/util/MockCollectionObject.php:
--------------------------------------------------------------------------------
1 | 2);
14 |
15 | public function testFoo() {
16 | return 'testFoo';
17 | }
18 |
19 | public function to($format, array $options = array()) {
20 | switch ($format) {
21 | case 'array':
22 | return $this->data + array(2 => 3);
23 | }
24 | }
25 | }
26 |
27 | ?>
--------------------------------------------------------------------------------
/action/DispatchException.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/cases/test/IntegrationTest.php:
--------------------------------------------------------------------------------
1 | run();
20 | $result = count($report);
21 |
22 | $this->assertEqual($expected, $result);
23 | }
24 | }
25 |
26 | ?>
--------------------------------------------------------------------------------
/tests/mocks/core/MockStaticInstantiator.php:
--------------------------------------------------------------------------------
1 | 'lithium\tests\mocks\core\MockRequest');
14 |
15 | public static function instance($name, array $config = array()) {
16 | return static::_instance($name, $config);
17 | }
18 |
19 | protected static function _foo() {
20 | return false;
21 | }
22 | }
23 |
24 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockDatabaseTag.php:
--------------------------------------------------------------------------------
1 | false, 'key' => 'id');
16 |
17 | protected $_schema = array(
18 | 'id' => array('type' => 'integer'),
19 | 'title' => array('type' => 'string'),
20 | 'created' => array('type' => 'datetime')
21 | );
22 | }
23 |
24 | ?>
--------------------------------------------------------------------------------
/tests/mocks/action/MockResponse.php:
--------------------------------------------------------------------------------
1 | testHeaders = array();
17 | parent::render();
18 | $this->headers = array();
19 | }
20 |
21 | protected function _writeHeaders($header, $code = null) {
22 | $this->testHeaders = array_merge($this->testHeaders, (array) $header);
23 | }
24 | }
25 |
26 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockDatabaseTagging.php:
--------------------------------------------------------------------------------
1 | false);
16 |
17 | protected $_schema = array(
18 | 'id' => array('type' => 'integer'),
19 | 'post_id' => array('type' => 'integer'),
20 | 'tag_id' => array('type' => 'integer')
21 | );
22 | }
23 |
24 | ?>
--------------------------------------------------------------------------------
/test/templates/complexity.html.php:
--------------------------------------------------------------------------------
1 | Cyclomatic Complexity
2 |
3 | $count): ?>
4 |
9 |
10 | | Worst Offender |
11 | |
12 |
13 |
14 |
15 | | Class Averages |
16 |
17 | $count): ?>
18 |
19 | |
20 | |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/tests/mocks/core/MockExposed.php:
--------------------------------------------------------------------------------
1 | _internal;
17 |
18 | return $this->_filter(__METHOD__, array(), function() use (&$internal) {
19 | $internal = 'tampered';
20 | return true;
21 | });
22 | }
23 |
24 | public function get() {
25 | return $this->_internal;
26 | }
27 | }
28 |
29 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockPost.php:
--------------------------------------------------------------------------------
1 | false, 'key' => 'id');
16 |
17 | public static function instances() {
18 | return array_keys(static::$_instances);
19 | }
20 |
21 | public function foobar() {
22 | return;
23 | }
24 |
25 | public function haveAnArray($someArray) {
26 | return;
27 | }
28 | }
29 |
30 | ?>
--------------------------------------------------------------------------------
/tests/mocks/template/helper/MockFormPostInfo.php:
--------------------------------------------------------------------------------
1 | false);
14 |
15 | protected $_schema = array(
16 | 'id' => array('type' => 'integer'),
17 | 'section' => array('type' => 'string'),
18 | 'notes' => array('type' => 'text'),
19 | 'created' => array('type' => 'datetime'),
20 | 'updated' => array('type' => 'datetime')
21 | );
22 | }
23 |
24 | ?>
--------------------------------------------------------------------------------
/test/templates/menu.html.php:
--------------------------------------------------------------------------------
1 | ");
5 |
6 | foreach ($path as $current => $value) {
7 | $path = trim(str_replace("//", "/", "{$parent}/{$current}"), "/");
8 | $result[] = "";
9 |
10 | if (is_string($value)) {
11 | $result[] = "{$current}";
13 | continue;
14 | }
15 | $result[] = "";
17 | $result[] = $self($self, $value, $path);
18 | $result[] = "";
19 | }
20 | $result[] = "";
21 | return join("\n", $result);
22 | };
23 | echo $render($render, $menu);
24 | ?>
--------------------------------------------------------------------------------
/tests/mocks/storage/session/adapter/MockPhp.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockTag.php:
--------------------------------------------------------------------------------
1 | array('to' => 'lithium\tests\mocks\data\model\MockImageTag')
15 | );
16 |
17 | protected $_meta = array(
18 | 'key' => 'id',
19 | 'name' => 'Tag',
20 | 'source' => 'mock_tag',
21 | 'connection' => false
22 | );
23 |
24 | protected $_schema = array(
25 | 'id' => array('type' => 'integer'),
26 | 'name' => array('type' => 'string')
27 | );
28 | }
29 |
30 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockDatabaseComment.php:
--------------------------------------------------------------------------------
1 | false);
16 |
17 | protected $_schema = array(
18 | 'id' => array('type' => 'integer'),
19 | 'post_id' => array('type' => 'integer'),
20 | 'author_id' => array('type' => 'integer'),
21 | 'body' => array('type' => 'text'),
22 | 'created' => array('type' => 'datetime')
23 | );
24 | }
25 |
26 | ?>
--------------------------------------------------------------------------------
/tests/mocks/template/helper/MockFormRenderer.php:
--------------------------------------------------------------------------------
1 | _request)) {
17 | $this->_request = new Request();
18 | $this->_request->params += array('controller' => 'posts', 'action' => 'add');
19 | }
20 | return $this->_request;
21 | }
22 |
23 | public function render($template, $data = array(), array $options = array()) {
24 | }
25 | }
26 |
27 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockQueryComment.php:
--------------------------------------------------------------------------------
1 | false);
16 |
17 | protected $_schema = array(
18 | 'id' => array('type' => 'integer', 'key' => 'primary'),
19 | 'author_id' => array('type' => 'integer'),
20 | 'comment' => array('type' => 'text'),
21 | 'created' => array('type' => 'datetime'),
22 | 'updated' => array('type' => 'datetime')
23 | );
24 | }
25 |
26 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockCreator.php:
--------------------------------------------------------------------------------
1 | false);
14 |
15 | protected $_schema = array(
16 | 'name' => array(
17 | 'default' => 'Moe',
18 | 'type' => 'string',
19 | 'null' => false
20 | ),
21 | 'sign' => array(
22 | 'default' => 'bar',
23 | 'type' => 'string',
24 | 'null' => false
25 | ),
26 | 'age' => array(
27 | 'default' => 0,
28 | 'type' => 'number',
29 | 'null' => false
30 | )
31 | );
32 | }
33 |
34 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockSubProduct.php:
--------------------------------------------------------------------------------
1 | 'mock_products', 'connection' => false);
14 |
15 | protected $_custom = array(
16 | 'prop2' => 'value2'
17 | );
18 |
19 | protected $_schema = array(
20 | 'refurb' => array('type' => 'boolean')
21 | );
22 |
23 | public $validates = array(
24 | 'refurb' => array(
25 | array(
26 | 'boolean',
27 | 'message' => 'Must have a boolean value.'
28 | )
29 | )
30 | );
31 | }
32 |
33 | ?>
--------------------------------------------------------------------------------
/tests/mocks/template/helper/MockFormPost.php:
--------------------------------------------------------------------------------
1 | false);
16 |
17 | protected $_schema = array(
18 | 'id' => array('type' => 'integer'),
19 | 'author_id' => array('type' => 'integer'),
20 | 'title' => array('type' => 'string'),
21 | 'body' => array('type' => 'text'),
22 | 'created' => array('type' => 'datetime'),
23 | 'updated' => array('type' => 'datetime')
24 | );
25 | }
26 |
27 | ?>
--------------------------------------------------------------------------------
/console/command/create/Model.php:
--------------------------------------------------------------------------------
1 | action);
30 | }
31 | }
32 |
33 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/export/testSaveHabtmWithFormCompatibleData.php:
--------------------------------------------------------------------------------
1 | '1',
4 | 'gallery_id' => NULL,
5 | 'image' => 'someimage.png',
6 | 'title' => 'Image1 Title',
7 | 'created' => NULL,
8 | 'modified' => NULL,
9 | 'images_tags' => array(
10 | 1 => array(
11 | 'id' => '1',
12 | 'image_id' => '1',
13 | 'tag_id' => '1',
14 | ),
15 | 2 => array(
16 | 'id' => '2',
17 | 'image_id' => '1',
18 | 'tag_id' => '3',
19 | ),
20 | 3 => array(
21 | 'id' => '3',
22 | 'image_id' => '1',
23 | 'tag_id' => '6',
24 | ),
25 | ),
26 | 'tags' => array(
27 | 1 => array(
28 | 'id' => '1',
29 | 'name' => 'High Tech'
30 | ),
31 | 3 => array(
32 | 'id' => '3',
33 | 'name' => 'Computer'
34 | ),
35 | 6 => array(
36 | 'id' => '6',
37 | 'name' => 'City'
38 | ),
39 | ),
40 | );
41 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockDatabasePostRevision.php:
--------------------------------------------------------------------------------
1 | false);
16 |
17 | protected $_schema = array(
18 | 'id' => array('type' => 'integer'),
19 | 'post_id' => array('type' => 'integer'),
20 | 'author_id' => array('type' => 'integer'),
21 | 'title' => array('type' => 'string'),
22 | 'deleted' => array('type' => 'datetime'),
23 | 'created' => array('type' => 'datetime')
24 | );
25 | }
26 |
27 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockQueryPost.php:
--------------------------------------------------------------------------------
1 | false, 'key' => 'id');
16 |
17 | protected $_schema = array(
18 | 'id' => array('type' => 'integer'),
19 | 'author_id' => array('type' => 'integer'),
20 | 'title' => array('type' => 'string', 'length' => 255),
21 | 'body' => array('type' => 'text'),
22 | 'created' => array('type' => 'datetime'),
23 | 'updated' => array('type' => 'datetime')
24 | );
25 | }
26 |
27 | ?>
--------------------------------------------------------------------------------
/tests/mocks/core/MockRequest.php:
--------------------------------------------------------------------------------
1 | params[$key])) {
21 | return $this->params[$key];
22 | }
23 | return null;
24 | }
25 |
26 | public function env($key) {
27 | if (isset($this->_config[$key])) {
28 | return $this->_config[$key];
29 | }
30 | return null;
31 | }
32 |
33 | public function get($key) {
34 | return $this->env($key);
35 | }
36 | }
37 |
38 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockModel.php:
--------------------------------------------------------------------------------
1 | false);
16 |
17 | public static function &connection($records = null) {
18 | $mock = new MockAdapter(compact('records') + array(
19 | 'columns' => array(
20 | 'lithium\tests\mocks\data\MockModel' => array('id', 'data')
21 | ),
22 | 'autoConnect' => false
23 | ));
24 | static::meta(array('key' => 'id', 'locked' => true));
25 | return $mock;
26 | }
27 | }
28 |
29 | ?>
--------------------------------------------------------------------------------
/console/command/G11n.php:
--------------------------------------------------------------------------------
1 | $this->request));
32 | return $extract->run();
33 | }
34 | }
35 |
36 | ?>
--------------------------------------------------------------------------------
/tests/mocks/g11n/catalog/adapter/MockGettext.php:
--------------------------------------------------------------------------------
1 | $file) {
21 | $extension = pathinfo($file, PATHINFO_EXTENSION);
22 |
23 | if ((!$this->mo && $extension === 'mo') || (!$this->po && $extension === 'po')) {
24 | unset($files[$key]);
25 | }
26 | }
27 | return $files;
28 | }
29 | }
30 |
31 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/source/MockMongoPost.php:
--------------------------------------------------------------------------------
1 | 'posts', 'connection' => false, 'key' => '_id');
16 |
17 | public static $connection;
18 |
19 | public static function schema($field = null) {
20 | $result = parent::schema($field);
21 |
22 | if (is_object($result) && get_class($result) === 'lithium\data\Schema') {
23 | return new Schema(array('fields' => $result->fields(), 'meta' => $result->meta()));
24 | }
25 | return $result;
26 | }
27 | }
28 |
29 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockDatabasePost.php:
--------------------------------------------------------------------------------
1 | array(
16 | 'constraints' => array('MockDatabasePostRevision.deleted' => null)
17 | )
18 | );
19 |
20 | protected $_meta = array('connection' => false, 'key' => 'id');
21 |
22 | protected $_schema = array(
23 | 'id' => array('type' => 'integer'),
24 | 'author_id' => array('type' => 'integer'),
25 | 'title' => array('type' => 'string'),
26 | 'created' => array('type' => 'datetime')
27 | );
28 | }
29 |
30 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockGallery.php:
--------------------------------------------------------------------------------
1 | array('to' => 'lithium\tests\mocks\data\model\MockImage')
15 | );
16 | public $belongsTo = array(
17 | 'Parent' => array('to' => 'lithium\tests\mocks\data\model\MockGallery')
18 | );
19 |
20 | protected $_meta = array(
21 | 'key' => 'id',
22 | 'name' => 'Gallery',
23 | 'source' => 'mock_gallery',
24 | 'connection' => false
25 | );
26 |
27 | protected $_schema = array(
28 | 'id' => array('type' => 'integer'),
29 | 'title' => array('type' => 'name')
30 | );
31 | }
32 |
33 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockImageTag.php:
--------------------------------------------------------------------------------
1 | array('to' => 'lithium\tests\mocks\data\model\MockImage'),
15 | 'Tag' => array('to' => 'lithium\tests\mocks\data\model\MockTag')
16 | );
17 |
18 | protected $_meta = array(
19 | 'key' => 'id',
20 | 'name' => 'ImageTag',
21 | 'source' => 'mock_image_tag',
22 | 'connection' => false
23 | );
24 |
25 | protected $_schema = array(
26 | 'id' => array('type' => 'integer'),
27 | 'image_id' => array('type' => 'integer'),
28 | 'tag_id' => array('type' => 'integer')
29 | );
30 | }
31 |
32 | ?>
--------------------------------------------------------------------------------
/tests/mocks/security/auth/adapter/MockAuthAdapter.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/TagsFixture.php:
--------------------------------------------------------------------------------
1 | array('type' => 'id'),
17 | 'name' => array('type' => 'string', 'length' => 50)
18 | );
19 |
20 | protected $_records = array(
21 | array('id' => 1, 'name' => 'High Tech'),
22 | array('id' => 2, 'name' => 'Sport'),
23 | array('id' => 3, 'name' => 'Computer'),
24 | array('id' => 4, 'name' => 'Art'),
25 | array('id' => 5, 'name' => 'Science'),
26 | array('id' => 6, 'name' => 'City')
27 | );
28 | }
29 |
30 | ?>
--------------------------------------------------------------------------------
/tests/cases/storage/cache/strategy/JsonTest.php:
--------------------------------------------------------------------------------
1 | Json = new Json();
17 | }
18 |
19 | public function testWrite() {
20 | $data = array('some' => 'data');
21 | $result = $this->Json->write($data);
22 | $expected = json_encode($data);
23 | $this->assertEqual($expected, $result);
24 | }
25 |
26 | public function testRead() {
27 | $expected = array('some' => 'data');
28 | $encoded = json_encode($expected);
29 | $result = $this->Json->read($encoded);
30 | $this->assertEqual($expected, $result);
31 | }
32 | }
33 |
34 | ?>
--------------------------------------------------------------------------------
/tests/cases/storage/cache/strategy/Base64Test.php:
--------------------------------------------------------------------------------
1 | Base64 = new Base64();
17 | }
18 |
19 | public function testWrite() {
20 | $data = 'a test string';
21 | $result = $this->Base64->write($data);
22 | $expected = base64_encode($data);
23 | $this->assertEqual($expected, $result);
24 | }
25 |
26 | public function testRead() {
27 | $expected = 'a test string';
28 | $encoded = base64_encode($expected);
29 | $result = $this->Base64->read($encoded);
30 | $this->assertEqual($expected, $result);
31 | }
32 | }
33 |
34 | ?>
--------------------------------------------------------------------------------
/tests/mocks/core/MockCallable.php:
--------------------------------------------------------------------------------
1 | construct = func_get_args();
23 | }
24 |
25 | public function __call($method, $params = array()) {
26 | return $this->call = compact('method', 'params');
27 | }
28 |
29 | public static function __callStatic($method, $params) {
30 | return static::$callStatic = compact('method', 'params');
31 | }
32 |
33 | public function __get($value) {
34 | return $this->get = $value;
35 | }
36 | }
37 |
38 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockModelCompositePk.php:
--------------------------------------------------------------------------------
1 | false);
16 |
17 | public static function &connection($records = null) {
18 | $mock = new MockAdapter(compact('records') + array(
19 | 'columns' => array(
20 | 'lithium\tests\mocks\data\MockModelCompositePk' => array(
21 | 'client_id', 'invoice_id', 'payment'
22 | )
23 | ),
24 | 'autoConnect' => false
25 | ));
26 | static::meta(array(
27 | 'key' => array('client_id', 'invoice_id'),
28 | 'locked' => true
29 | ));
30 | return $mock;
31 | }
32 | }
33 |
34 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/export/testOneToMany.php:
--------------------------------------------------------------------------------
1 | array(
4 | 'id' => '1',
5 | 'name' => 'Foo Gallery',
6 | 'active' => '1',
7 | 'created' => '2007-06-20 21:02:27',
8 | 'modified' => '2009-12-14 22:36:09',
9 | 'images' => array(
10 | array(
11 | 'id' => '1',
12 | 'gallery_id' => '1',
13 | 'image' => 'someimage.png',
14 | 'title' => 'Amiga 1200',
15 | 'created' => '2011-05-22 10:43:13',
16 | 'modified' => '2012-11-30 18:38:10',
17 | ),
18 | array(
19 | 'id' => '2',
20 | 'gallery_id' => '1',
21 | 'image' => 'image.jpg',
22 | 'title' => 'Srinivasa Ramanujan',
23 | 'created' => '2009-01-05 08:39:27',
24 | 'modified' => '2009-03-14 05:42:07',
25 | ),
26 | array(
27 | 'id' => '3',
28 | 'gallery_id' => '1',
29 | 'image' => 'photo.jpg',
30 | 'title' => 'Las Vegas',
31 | 'created' => '2010-08-11 23:12:03',
32 | 'modified' => '2010-09-24 04:45:14',
33 | ),
34 | ),
35 | ),
36 | );
37 | ?>
--------------------------------------------------------------------------------
/tests/mocks/console/MockDispatcherCommand.php:
--------------------------------------------------------------------------------
1 | 'lithium\tests\mocks\console\MockResponse'
17 | );
18 |
19 | public function testRun() {
20 | $this->response->testAction = __FUNCTION__;
21 | }
22 |
23 | public function run($param = null) {
24 | $this->response->testAction = __FUNCTION__;
25 | $this->response->testParam = $param;
26 | }
27 |
28 | public function testAction() {
29 | $this->response->testAction = __FUNCTION__;
30 | }
31 |
32 | public function testEnv() {
33 | $this->response->environment = Environment::get();
34 | }
35 | }
36 |
37 | ?>
--------------------------------------------------------------------------------
/tests/cases/storage/cache/strategy/SerializerTest.php:
--------------------------------------------------------------------------------
1 | Serializer = new Serializer();
17 | }
18 |
19 | public function testWrite() {
20 | $data = array('some' => 'data');
21 | $result = $this->Serializer->write($data);
22 | $expected = serialize($data);
23 | $this->assertEqual($expected, $result);
24 | }
25 |
26 | public function testRead() {
27 | $encoded = 'a:1:{s:4:"some";s:4:"data";}';
28 | $expected = unserialize($encoded);
29 | $result = $this->Serializer->read($encoded);
30 | $this->assertEqual($expected, $result);
31 | }
32 | }
33 |
34 | ?>
--------------------------------------------------------------------------------
/tests/mocks/console/MockResponse.php:
--------------------------------------------------------------------------------
1 | output = null;
22 | $this->error = null;
23 | }
24 |
25 | public function output($output) {
26 | return $this->output .= String::insert($output, $this->styles(false));
27 | }
28 |
29 | public function error($error) {
30 | return $this->error .= String::insert($error, $this->styles(false));
31 | }
32 |
33 | public function __destruct() {
34 | $this->output = null;
35 | $this->error = null;
36 | }
37 | }
38 |
39 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockImage.php:
--------------------------------------------------------------------------------
1 | array('to' => 'lithium\tests\mocks\data\model\MockGallery')
15 | );
16 |
17 | public $hasMany = array(
18 | 'ImageTag' => array('to' => 'lithium\tests\mocks\data\model\MockImageTag')
19 | );
20 |
21 | protected $_meta = array(
22 | 'key' => 'id',
23 | 'name' => 'Image',
24 | 'source' => 'mock_image',
25 | 'connection' => false
26 | );
27 |
28 | protected $_schema = array(
29 | 'id' => array('type' => 'integer'),
30 | 'title' => array('type' => 'string'),
31 | 'image' => array('type' => 'string'),
32 | 'gallery_id' => array('type' => 'integer')
33 | );
34 | }
35 |
36 | ?>
--------------------------------------------------------------------------------
/tests/cases/net/SocketTest.php:
--------------------------------------------------------------------------------
1 | open(array('test' => true));
19 | $config = $socket->config();
20 | $this->assertTrue($config['test']);
21 | }
22 |
23 | public function testSend() {
24 | $socket = new MockSocket();
25 | $message = new Request();
26 | $response = $socket->send($message, array('response' => 'lithium\net\http\Response'));
27 | $this->assertInstanceOf('lithium\net\http\Response', $response);
28 | $this->assertInstanceOf('lithium\net\http\Request', $socket->data);
29 | }
30 | }
31 |
32 | ?>
--------------------------------------------------------------------------------
/tests/mocks/g11n/multibyte/adapter/MockAdapter.php:
--------------------------------------------------------------------------------
1 | testStrlenArgs = func_get_args();
27 | }
28 |
29 | public function strpos() {
30 | $this->testStrposArgs = func_get_args();
31 | }
32 |
33 | public function strrpos() {
34 | $this->testStrrposArgs = func_get_args();
35 | }
36 |
37 | public function substr() {
38 | $this->testSubstrArgs = func_get_args();
39 | }
40 | }
41 |
42 | ?>
--------------------------------------------------------------------------------
/tests/mocks/action/MockDispatcher.php:
--------------------------------------------------------------------------------
1 | params = $params;
27 | return $callable;
28 | }
29 |
30 | protected static function _call($callable, $request, $params) {
31 | if (is_callable($callable->params['controller'])) {
32 | return parent::_call($callable->params['controller'], $request, $params);
33 | }
34 | static::$dispatched[] = $callable;
35 | }
36 | }
37 |
38 | ?>
--------------------------------------------------------------------------------
/tests/mocks/template/view/adapters/TestRenderer.php:
--------------------------------------------------------------------------------
1 | _paths[$type] as $path) {
13 | if (!file_exists($path = String::insert($path, $params))) {
14 | continue;
15 | }
16 | self::$templateData[] = compact('type', 'params') + array(
17 | 'return' => $path
18 | );
19 | return $path;
20 | }
21 | self::$templateData[] = compact('type', 'params') + array(
22 | 'return' => false
23 | );
24 | return false;
25 | }
26 |
27 | public function render($template, $data = array(), array $options = array()) {
28 | self::$renderData[] = compact('template', 'data', 'options');
29 | ob_start();
30 | include $template;
31 | return ob_get_clean();
32 | }
33 | }
34 |
35 | ?>
--------------------------------------------------------------------------------
/test/templates/errors.txt.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/data/model/mock_database/MockResult.php:
--------------------------------------------------------------------------------
1 | _iterator < count($this->_records)) {
24 | $result = current($this->_records);
25 | $this->_key = $this->_iterator;
26 | $this->_current = $this->_cache[$this->_iterator++] = $result;
27 | next($this->_records);
28 | return true;
29 | }
30 | return false;
31 | }
32 |
33 | protected function _close() {
34 | }
35 | }
36 |
37 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/source/http/adapter/MockCouchPost.php:
--------------------------------------------------------------------------------
1 | 'posts', 'connection' => false, 'key' => 'id');
16 |
17 | protected $_schema = array(
18 | 'id' => array('type' => 'integer'),
19 | 'author_id' => array('type' => 'integer'),
20 | 'title' => array('type' => 'string', 'length' => 255),
21 | 'body' => array('type' => 'text'),
22 | 'created' => array('type' => 'datetime'),
23 | 'updated' => array('type' => 'datetime')
24 | );
25 |
26 | public static function resetSchema($array = false) {
27 | if ($array) {
28 | return static::_object()->_schema = array();
29 | }
30 | static::_object()->_schema = new DocumentSchema();
31 | }
32 | }
33 |
34 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/source/MockHttpModel.php:
--------------------------------------------------------------------------------
1 | 'posts',
17 | 'connection' => false
18 | );
19 |
20 | public static $connection = null;
21 |
22 | protected $_schema = array(
23 | 'id' => array('type' => 'integer', 'key' => 'primary'),
24 | 'author_id' => array('type' => 'integer'),
25 | 'title' => array('type' => 'string', 'length' => 255),
26 | 'body' => array('type' => 'text'),
27 | 'created' => array('type' => 'datetime'),
28 | 'updated' => array('type' => 'datetime')
29 | );
30 |
31 | public static function &connection() {
32 | if (static::$connection) {
33 | return static::$connection;
34 | }
35 | $result = new Http();
36 | return $result;
37 | }
38 | }
39 |
40 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/source/MockMongoSource.php:
--------------------------------------------------------------------------------
1 | queries[] = compact('data', 'options');
26 | $result = current($this->resultSets);
27 | next($this->resultSets);
28 | $data['_id'] = new MongoId();
29 | return $result;
30 | }
31 |
32 | public function find($conditions, $fields) {
33 | $this->queries[] = compact('conditions', 'fields');
34 | $result = new MockResult(array('data' => current($this->resultSets)));
35 | next($this->resultSets);
36 | return $result;
37 | }
38 | }
39 |
40 | ?>
--------------------------------------------------------------------------------
/tests/mocks/core/MockObjectConfiguration.php:
--------------------------------------------------------------------------------
1 | _autoConfig = (array) $config['autoConfig'];
22 | unset($config['autoConfig']);
23 | }
24 | parent::__construct($config);
25 | }
26 |
27 | public function testScalar($value) {
28 | $this->_testScalar = 'called';
29 | }
30 |
31 | public function getProtected() {
32 | return $this->_protected;
33 | }
34 |
35 | public function getConfig() {
36 | return array(
37 | 'testScalar' => $this->_testScalar,
38 | 'testArray' => $this->_testArray
39 | );
40 | }
41 | }
42 |
43 | ?>
--------------------------------------------------------------------------------
/data/source/mongo_db/Result.php:
--------------------------------------------------------------------------------
1 | _resource && $this->_resource->hasNext()) {
30 | $result = $this->_resource->getNext();
31 | $isFile = ($result instanceof MongoGridFSFile);
32 | $result = $isFile ? array('file' => $result) + $result->file : $result;
33 | $this->_key = $this->_iterator;
34 | $this->_current = $result;
35 | return true;
36 | }
37 | return false;
38 | }
39 | }
40 |
41 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/ImagesTagsFixture.php:
--------------------------------------------------------------------------------
1 | array('type' => 'id'),
17 | 'image_id' => array('type' => 'integer', 'length' => 11),
18 | 'tag_id' => array('type' => 'integer', 'length' => 11)
19 | );
20 |
21 | protected $_records = array(
22 | array('id' => 1, 'image_id' => 1, 'tag_id' => 1),
23 | array('id' => 2, 'image_id' => 1, 'tag_id' => 3),
24 | array('id' => 3, 'image_id' => 2, 'tag_id' => 5),
25 | array('id' => 4, 'image_id' => 3, 'tag_id' => 6),
26 | array('id' => 5, 'image_id' => 4, 'tag_id' => 6),
27 | array('id' => 6, 'image_id' => 4, 'tag_id' => 3),
28 | array('id' => 7, 'image_id' => 4, 'tag_id' => 1)
29 | );
30 | }
31 |
32 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/collection/MockRecordSet.php:
--------------------------------------------------------------------------------
1 | _closed = true;
15 | }
16 | /**
17 | * Convenience method for lazy loading testing
18 | * Reset the `RecordSet` to its inital state after `_construct`
19 | *
20 | */
21 | public function reset() {
22 | if (is_object($this->_result) && method_exists($this->_result, 'rewind')) {
23 | $this->_closed = false;
24 | $this->_init = false;
25 | $this->_started = false;
26 | $this->_valid = false;
27 | $this->_data = array();
28 | $this->_index = array();
29 | $this->_result->rewind();
30 | $this->_columns = $this->_columnMap();
31 | return true;
32 | }
33 | return false;
34 | }
35 |
36 | public function get($var) {
37 | return $this->{$var};
38 | }
39 | }
40 |
41 | ?>
--------------------------------------------------------------------------------
/storage/cache/strategy/Serializer.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/data/collection/MockMultiKeyRecordSet.php:
--------------------------------------------------------------------------------
1 | _closed = true;
15 | }
16 | /**
17 | * Convenience method for lazy loading testing
18 | * Reset the `MultiKeyRecordSet` to its inital state after `_construct`
19 | *
20 | */
21 | public function reset() {
22 | if (is_object($this->_result) && method_exists($this->_result, 'rewind')) {
23 | $this->_closed = false;
24 | $this->_init = false;
25 | $this->_started = false;
26 | $this->_valid = false;
27 | $this->_data = array();
28 | $this->_index = array();
29 | $this->_result->rewind();
30 | $this->_columns = $this->_columnMap();
31 | return true;
32 | }
33 | return false;
34 | }
35 |
36 | public function get($var) {
37 | return $this->{$var};
38 | }
39 | }
40 |
41 | ?>
--------------------------------------------------------------------------------
/tests/mocks/template/MockHelper.php:
--------------------------------------------------------------------------------
1 | '{:title}');
14 |
15 | /**
16 | * Hack to expose protected properties for testing.
17 | *
18 | * @param string $property
19 | * @return mixed
20 | */
21 | public function __get($property) {
22 | return isset($this->{$property}) ? $this->{$property} : null;
23 | }
24 |
25 | public function testOptions($defaults, $options) {
26 | return $this->_options($defaults, $options);
27 | }
28 |
29 | public function testAttributes($params, $method = null, array $options = array()) {
30 | return $this->_attributes($params, $method, $options);
31 | }
32 |
33 | public function testRender($method, $string, $params, array $options = array()) {
34 | return $this->_render($method, $string, $params, $options);
35 | }
36 | }
37 |
38 | ?>
--------------------------------------------------------------------------------
/storage/cache/strategy/Base64.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/cases/template/view/adapter/SimpleTest.php:
--------------------------------------------------------------------------------
1 | subject = new Simple();
20 | }
21 |
22 | public function testBasicRender() {
23 | $result = $this->subject->template('layout', array('layout' => '{:content}'));
24 | $expected = '{:content}';
25 | $this->assertEqual($expected, $result);
26 |
27 | $message = new MockStringObject();
28 | $message->message = 'Lithium is about to rock you.';
29 |
30 | $result = $this->subject->render('Hello {:name}! {:message}', compact('message') + array(
31 | 'name' => 'World'
32 | ));
33 | $expected = 'Hello World! Lithium is about to rock you.';
34 | $this->assertEqual($expected, $result);
35 | }
36 | }
37 |
38 | ?>
--------------------------------------------------------------------------------
/tests/mocks/core/MockMethodFiltering.php:
--------------------------------------------------------------------------------
1 | _filter(__METHOD__, compact('data'), function($self, $params, $chain) {
16 | $params['data'][] = 'Inside method implementation';
17 | return $params['data'];
18 | });
19 | $result[] = 'Ending outer method call';
20 | return $result;
21 | }
22 |
23 | public function method2() {
24 | $filters =& $this->_methodFilters;
25 | $method = function($self, $params, $chain) use (&$filters) {
26 | return $filters;
27 | };
28 | return $this->_filter(__METHOD__, array(), $method);
29 | }
30 |
31 | public function manual($filters) {
32 | $method = function($self, $params, $chain) {
33 | return "Working";
34 | };
35 | return $this->_filter(__METHOD__, array(), $method, $filters);
36 | }
37 |
38 | }
39 |
40 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/GalleriesFixture.php:
--------------------------------------------------------------------------------
1 | array('type' => 'id'),
17 | 'name' => array('type' => 'string', 'length' => 50),
18 | 'active' => array('type' => 'boolean', 'default' => true),
19 | 'created' => array('type' => 'datetime'),
20 | 'modified' => array('type' => 'datetime')
21 | );
22 |
23 | protected $_records = array(
24 | array(
25 | 'id' => 1,
26 | 'name' => 'Foo Gallery',
27 | 'active' => true,
28 | 'created' => '2007-06-20 21:02:27',
29 | 'modified' => '2009-12-14 22:36:09'
30 | ),
31 | array(
32 | 'id' => 2,
33 | 'name' => 'Bar Gallery',
34 | 'active' => true,
35 | 'created' => '2008-08-22 16:12:42',
36 | 'modified' => '2008-08-22 16:12:42'
37 | ),
38 | );
39 | }
40 |
41 | ?>
--------------------------------------------------------------------------------
/tests/mocks/storage/cache/strategy/MockSerializer.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/cases/data/SchemaTest.php:
--------------------------------------------------------------------------------
1 | array(
17 | 'id' => 'int',
18 | 'name' => 'string',
19 | 'active' => array('type' => 'boolean', 'default' => true)
20 | )));
21 |
22 | $this->assertEqual('int', $schema->type('id'));
23 | $this->assertEqual('string', $schema->type('name'));
24 | $this->assertEqual('boolean', $schema->type('active'));
25 | $this->assertEqual(array('type' => 'int'), $schema->fields('id'));
26 | $this->assertEqual(array('id', 'name', 'active'), $schema->names());
27 |
28 | $expected = array(
29 | 'id' => array('type' => 'int'),
30 | 'name' => array('type' => 'string'),
31 | 'active' => array('type' => 'boolean', 'default' => true)
32 | );
33 | $this->assertEqual($expected, $schema->fields());
34 | }
35 | }
36 |
37 | ?>
--------------------------------------------------------------------------------
/tests/mocks/storage/session/strategy/MockCookieSession.php:
--------------------------------------------------------------------------------
1 | 'foo', 'two' => 'bar');
16 |
17 | public static function read($key = null, array $options = array()) {
18 | if (isset(static::$_data[$key])) {
19 | return static::$_data[$key];
20 | }
21 | return static::$_data;
22 | }
23 |
24 | public static function write($key, $value = null, array $options = array()) {
25 | static::$_data[$key] = $value;
26 | return $value;
27 | }
28 |
29 | public static function reset() {
30 | return static::$_data = array('one' => 'foo', 'two' => 'bar');
31 | }
32 |
33 | /**
34 | * Method for returning data currently stored in this mock.
35 | *
36 | * @return array
37 | */
38 | public static function data() {
39 | return static::$_data;
40 | }
41 | }
42 |
43 | ?>
--------------------------------------------------------------------------------
/storage/cache/strategy/Json.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/mocks/storage/cache/strategy/MockConfigurizer.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/ci/config/libraries.php:
--------------------------------------------------------------------------------
1 | true,
23 | 'resources' => call_user_func(function() {
24 | if (is_dir($resources = str_replace("//", "/", sys_get_temp_dir() . '/resources'))) {
25 | return $resources;
26 | }
27 | foreach (array($resources, "{$resources}/logs", "{$resources}/tmp/cache/templates") as $d) {
28 | mkdir($d, 0777, true);
29 | }
30 | return $resources;
31 | })
32 | ));
33 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/export/testManyToOne.php:
--------------------------------------------------------------------------------
1 | array(
4 | 'id' => '1',
5 | 'gallery_id' => '1',
6 | 'image' => 'someimage.png',
7 | 'title' => 'Amiga 1200',
8 | 'created' => '2011-05-22 10:43:13',
9 | 'modified' => '2012-11-30 18:38:10',
10 | 'gallery' => array(
11 | 'id' => '1',
12 | 'name' => 'Foo Gallery',
13 | 'active' => '1',
14 | 'created' => '2007-06-20 21:02:27',
15 | 'modified' => '2009-12-14 22:36:09',
16 | ),
17 | ),
18 | 2 => array(
19 | 'id' => '2',
20 | 'gallery_id' => '1',
21 | 'image' => 'image.jpg',
22 | 'title' => 'Srinivasa Ramanujan',
23 | 'created' => '2009-01-05 08:39:27',
24 | 'modified' => '2009-03-14 05:42:07',
25 | 'gallery' => array(
26 | 'id' => '1',
27 | 'name' => 'Foo Gallery',
28 | 'active' => '1',
29 | 'created' => '2007-06-20 21:02:27',
30 | 'modified' => '2009-12-14 22:36:09',
31 | ),
32 | ),
33 | 3 => array(
34 | 'id' => '3',
35 | 'gallery_id' => '1',
36 | 'image' => 'photo.jpg',
37 | 'title' => 'Las Vegas',
38 | 'created' => '2010-08-11 23:12:03',
39 | 'modified' => '2010-09-24 04:45:14',
40 | 'gallery' => array(
41 | 'id' => '1',
42 | 'name' => 'Foo Gallery',
43 | 'active' => '1',
44 | 'created' => '2007-06-20 21:02:27',
45 | 'modified' => '2009-12-14 22:36:09',
46 | ),
47 | ),
48 | );
49 | ?>
--------------------------------------------------------------------------------
/test/templates/stats.html.php:
--------------------------------------------------------------------------------
1 |
9 |
10 | /
11 | ,
12 |
13 | and
14 |
15 |
16 |
17 |
18 | render("{$error['result']}", compact('error')); ?>
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | Skipped test
28 |
29 |
30 |
--------------------------------------------------------------------------------
/tests/mocks/test/MockStdClass.php:
--------------------------------------------------------------------------------
1 | _data[$key] = $value;
11 | }
12 |
13 | public function &__get($key) {
14 | if (isset($this->_data[$key])) {
15 | $data =& $this->_data[$key];
16 | return $data;
17 | }
18 | $data = null;
19 | return $data;
20 | }
21 |
22 | public function &data() {
23 | $data =& $this->_data;
24 | return $data;
25 | }
26 |
27 | public function filterableData() {
28 | return $this->_data;
29 | }
30 |
31 | public function method1() {
32 | return true;
33 | }
34 |
35 | public function method2() {
36 | return false;
37 | }
38 |
39 | public function getClass() {
40 | return get_class($this);
41 | }
42 |
43 | public function isExecutable() {
44 | return is_executable(__FILE__);
45 | }
46 |
47 | public static function methodFoo() {
48 | return true;
49 | }
50 |
51 | public function __call($method, $params) {
52 | return $this->methodFoo();
53 | }
54 |
55 | public static function __callStatic($method, $params) {
56 | return static::methodFoo();
57 | }
58 |
59 | public function methodBar() {
60 | $this->methodBaz(1);
61 | return $this->__call('methodBaz', array(2));
62 | }
63 |
64 | }
65 |
66 | ?>
--------------------------------------------------------------------------------
/tests/cases/g11n/catalog/adapter/MemoryTest.php:
--------------------------------------------------------------------------------
1 | adapter = new Memory();
19 | }
20 |
21 | public function tearDown() {
22 | }
23 |
24 | public function testReadAndWrite() {
25 | $data = array(
26 | 'singular 1' => array(
27 | 'id' => 'singular 1',
28 | 'ids' => array('singular' => 'singular 1', 'plural' => 'plural 1'),
29 | 'flags' => array('fuzzy' => true),
30 | 'translated' => array(),
31 | 'occurrences' => array(
32 | array('file' => 'test.php', 'line' => 1)
33 | ),
34 | 'comments' => array(
35 | 'comment 1'
36 | )
37 | )
38 | );
39 | $result = $this->adapter->write('category', 'ja', 'default', $data);
40 | $this->assertEqual($data, $this->adapter->read('category', 'ja', 'default'));
41 | }
42 |
43 | public function testReadNonExistent() {
44 | $result = $this->adapter->read('messageTemplate', 'root', null);
45 | $this->assertEmpty($result);
46 | }
47 | }
48 |
49 | ?>
--------------------------------------------------------------------------------
/tests/mocks/test/MockUnitTest.php:
--------------------------------------------------------------------------------
1 | assertTrue(true);
15 | }
16 |
17 | /**
18 | * This method is used in a test and is *line sensitive*. The corresponding
19 | * test's expectations needs to be adapted if the line of the `assert()`
20 | * call changes.
21 | *
22 | * @see lithium\tests\cases\test\UnitTest::testAssertBacktraces()
23 | */
24 | public function testSomething() {
25 | $this->assert(true);
26 | }
27 |
28 | /**
29 | * This method is used in a test to prepare it.
30 | *
31 | * @see lithium\tests\cases\test\UnitTest::testExpectExceptionNotThrown()
32 | */
33 | public function prepareTestExpectExceptionNotThrown() {
34 | $this->expectException('test');
35 | }
36 |
37 | public function compare($type, $expected, $result = null, $trace = null) {
38 | return parent::_compare($type, $expected, $result, $trace);
39 | }
40 |
41 | public function handleException($exception, $lineFlag = null) {
42 | return parent::_handleException($exception, $lineFlag);
43 | }
44 |
45 | public function expected() {
46 | return $this->_expected;
47 | }
48 | }
49 |
50 | ?>
--------------------------------------------------------------------------------
/console/command/create/template/controller.txt.php:
--------------------------------------------------------------------------------
1 | namespace {:namespace};
2 |
3 | use {:use};
4 | use lithium\action\DispatchException;
5 |
6 | class {:class} extends \lithium\action\Controller {
7 |
8 | public function index() {
9 | ${:plural} = {:model}::all();
10 | return compact('{:plural}');
11 | }
12 |
13 | public function view() {
14 | ${:singular} = {:model}::first($this->request->id);
15 | return compact('{:singular}');
16 | }
17 |
18 | public function add() {
19 | ${:singular} = {:model}::create();
20 |
21 | if (($this->request->data) && ${:singular}->save($this->request->data)) {
22 | return $this->redirect(array('{:name}::view', 'args' => array(${:singular}->id)));
23 | }
24 | return compact('{:singular}');
25 | }
26 |
27 | public function edit() {
28 | ${:singular} = {:model}::find($this->request->id);
29 |
30 | if (!${:singular}) {
31 | return $this->redirect('{:name}::index');
32 | }
33 | if (($this->request->data) && ${:singular}->save($this->request->data)) {
34 | return $this->redirect(array('{:name}::view', 'args' => array(${:singular}->id)));
35 | }
36 | return compact('{:singular}');
37 | }
38 |
39 | public function delete() {
40 | if (!$this->request->is('post') && !$this->request->is('delete')) {
41 | $msg = "{:name}::delete can only be called with http:post or http:delete.";
42 | throw new DispatchException($msg);
43 | }
44 | {:model}::find($this->request->id)->delete();
45 | return $this->redirect('{:name}::index');
46 | }
47 | }
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockDocumentMultipleKey.php:
--------------------------------------------------------------------------------
1 | array('id', 'rev'),
17 | 'name' => null,
18 | 'title' => null,
19 | 'class' => null,
20 | 'source' => null,
21 | 'connection' => false,
22 | 'initialized' => false
23 | );
24 |
25 | public function ret($record, $param1 = null, $param2 = null) {
26 | if ($param2) {
27 | return $param2;
28 | }
29 | if ($param1) {
30 | return $param1;
31 | }
32 | return null;
33 | }
34 |
35 | public static function find($type = 'all', array $options = array()) {
36 | if ($type === 'first') {
37 | return new Document(array('data' => array(
38 | 'id' => 2, 'rev' => '1-1', 'name' => 'Two', 'content' => 'Lorem ipsum two'
39 | )));
40 | }
41 |
42 | return new Document(array('data' => array(
43 | array('id' => 1, 'rev' => '1-1','name' => 'One', 'content' => 'Lorem ipsum one'),
44 | array('id' => 2, 'rev' => '1-1','name' => 'Two', 'content' => 'Lorem ipsum two'),
45 | array('id' => 3, 'rev' => '1-1', 'name' => 'Three', 'content' => 'Lorem ipsum three')
46 | )));
47 | }
48 | }
49 |
50 | ?>
--------------------------------------------------------------------------------
/tests/integration/analysis/LoggerTest.php:
--------------------------------------------------------------------------------
1 | skipIf(!is_writable($base), "Path `{$base}` is not writable.");
24 |
25 | Filters::apply('lithium\analysis\Logger', 'write', function($self, $params, $chain) {
26 | $params['message'] = 'Filtered Message';
27 | return $chain->next($self, $params, $chain);
28 | });
29 |
30 | $config = array('default' => array(
31 | 'adapter' => 'File', 'timestamp' => false, 'format' => "{:message}\n"
32 | ));
33 | Logger::config($config);
34 |
35 | $result = Logger::write('info', 'Original Message');
36 | $this->assertFileExists($base . '/info.log');
37 |
38 | $expected = "Filtered Message\n";
39 | $result = file_get_contents($base . '/info.log');
40 | $this->assertEqual($expected, $result);
41 |
42 | Filters::apply('lithium\analysis\Logger', 'write', false);
43 | unlink($base . '/info.log');
44 | }
45 | }
46 |
47 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockPostForValidates.php:
--------------------------------------------------------------------------------
1 | 'mock_posts', 'connection' => false);
16 |
17 | public $validates = array(
18 | 'title' => 'please enter a title',
19 | 'email' => array(
20 | array('notEmpty', 'message' => 'email is empty'),
21 | array('email', 'message' => 'email is not valid'),
22 | array('modelIsSet', 'required' => false, 'message' => 'model is not set'),
23 | array(
24 | 'inList',
25 | 'list' => array('something@test.com','foo@bar.com'),
26 | 'on' => 'customEvent',
27 | 'message' => 'email is not in 1st list'
28 | ),
29 | array(
30 | 'inList',
31 | 'list' => array('something@test.com'),
32 | 'on' => 'anotherCustomEvent',
33 | 'message' => 'email is not in 2nd list'
34 | )
35 | )
36 | );
37 |
38 | public static function init() {
39 | $class = __CLASS__;
40 | Validator::add('modelIsSet', function($value, $format, $options) use ($class) {
41 | if (isset($options['model']) && $options['model'] = $class) {
42 | return true;
43 | }
44 | return false;
45 | });
46 | }
47 | }
48 |
49 | MockPostForValidates::init();
50 |
51 | ?>
--------------------------------------------------------------------------------
/tests/cases/data/source/mongo_db/SchemaTest.php:
--------------------------------------------------------------------------------
1 | skipIf(!MongoDb::enabled(), 'MongoDb is not enabled');
21 | }
22 |
23 | public function setUp() {
24 | $this->_db = new MongoDb(array('autoConnect' => false));
25 | }
26 |
27 | public function testCastingIdArray() {
28 | $schema = new Schema(array('fields' => array(
29 | '_id' => array('type' => 'id'),
30 | 'users' => array('type' => 'id', 'array' => true)
31 | )));
32 |
33 | $result = $schema->cast(null, null, array('users' => new MongoId()), array(
34 | 'database' => $this->_db
35 | ));
36 |
37 | $this->assertEqual(array('users'), array_keys($result->data()));
38 | $this->assertCount(1, $result->users);
39 | $this->assertInstanceOf('MongoId', $result->users[0]);
40 | }
41 |
42 | public function testCastingEmptyValues() {
43 | $schema = new Schema(array('fields' => array(
44 | '_id' => array('type' => 'id'),
45 | 'foo' => array('type' => 'string', 'array' => true)
46 | )));
47 | $result = $schema->cast(null, null, null, array('database' => $this->_db));
48 | }
49 | }
50 |
51 | ?>
--------------------------------------------------------------------------------
/tests/integration/net/http/ServiceTest.php:
--------------------------------------------------------------------------------
1 | 'www.google.com',
18 | 'classes' => array('socket' => 'lithium\net\socket\Stream')
19 | ));
20 | $service->head();
21 |
22 | $expected = array('code' => 200, 'message' => 'OK');
23 | $result = $service->last->response->status;
24 | $this->assertEqual($expected, $result);
25 | }
26 |
27 | public function testContextGet() {
28 | $service = new Service(array(
29 | 'host' => 'www.google.com',
30 | 'classes' => array('socket' => 'lithium\net\socket\Context')
31 | ));
32 | $service->head();
33 |
34 | $expected = array('code' => 200, 'message' => 'OK');
35 | $result = $service->last->response->status;
36 | $this->assertEqual($expected, $result);
37 | }
38 |
39 | public function testCurlGet() {
40 | $service = new Service(array(
41 | 'host' => 'www.google.com',
42 | 'classes' => array('socket' => 'lithium\net\socket\Curl')
43 | ));
44 | $service->head();
45 |
46 | $expected = array('code' => 200, 'message' => 'OK');
47 | $result = $service->last->response->status;
48 | $this->assertEqual($expected, $result);
49 | }
50 | }
51 |
52 | ?>
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2014, Union of RAD http://union-of-rad.org
2 | All rights reserved.
3 |
4 | Redistribution and use in source and binary forms, with or without modification,
5 | are permitted provided that the following conditions are met:
6 |
7 | * Redistributions of source code must retain the above copyright notice,
8 | this list of conditions and the following disclaimer.
9 | * Redistributions in binary form must reproduce the above copyright notice,
10 | this list of conditions and the following disclaimer in the documentation
11 | and/or other materials provided with the distribution.
12 | * Neither the name of Lithium, Union of Rad, nor the names of its contributors
13 | may be used to endorse or promote products derived from this software
14 | without specific prior written permission.
15 |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
20 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
24 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 |
--------------------------------------------------------------------------------
/tests/mocks/data/MockProduct.php:
--------------------------------------------------------------------------------
1 | 'mock_products', 'connection' => false);
14 |
15 | protected $_inherits = array('_custom');
16 |
17 | protected $_custom = array(
18 | 'prop1' => 'value1'
19 | );
20 |
21 | protected $_schema = array(
22 | 'id' => array('type' => 'id'),
23 | 'name' => array('type' => 'string', 'null' => false),
24 | 'price' => array('type' => 'string', 'null' => false),
25 | );
26 |
27 | public $hasOne = array('MockCreator');
28 |
29 | public $validates = array(
30 | 'name' => array(
31 | array(
32 | 'notEmpty',
33 | 'message' => 'Name cannot be empty.'
34 | )
35 | ),
36 | 'price' => array(
37 | array(
38 | 'notEmpty',
39 | 'message' => 'Price cannot be empty.'
40 | ),
41 | array(
42 | 'numeric',
43 | 'message' => 'Price must have a numeric value.'
44 | )
45 | )
46 | );
47 |
48 | public static function finders() {
49 | $self = static::_object();
50 | return $self->_finders;
51 | }
52 |
53 | public static function initializers() {
54 | $self = static::_object();
55 | return $self->_initializers;
56 | }
57 |
58 | public static function attribute($name) {
59 | $self = static::_object();
60 | return isset($self->$name) ? $self->$name : null;
61 | }
62 | }
63 |
64 | ?>
--------------------------------------------------------------------------------
/test/Filter.php:
--------------------------------------------------------------------------------
1 | results['filters'][get_called_class()];
36 | }
37 |
38 | /**
39 | * Returns data to be output by a reporter.
40 | *
41 | * @param string $format I.e. `'html'` or `'text'`.
42 | * @param array $analysis The results of the analysis.
43 | * @return string
44 | */
45 | public static function output($format, $analysis) {}
46 | }
47 |
48 | ?>
--------------------------------------------------------------------------------
/tests/cases/analysis/logger/adapter/SyslogTest.php:
--------------------------------------------------------------------------------
1 | syslog = new Syslog();
21 | Logger::config(array('syslog' => array('adapter' => $this->syslog)));
22 | }
23 |
24 | public function testConfiguration() {
25 | $loggers = Logger::config();
26 | $result = isset($loggers['syslog']);
27 | $this->assertTrue($result);
28 | }
29 |
30 | public function testConstruct() {
31 | $expected = array(
32 | 'identity' => false,
33 | 'options' => LOG_ODELAY,
34 | 'facility' => LOG_USER,
35 | 'init' => true
36 | );
37 | $result = $this->syslog->_config;
38 | $this->assertEqual($expected, $result);
39 |
40 | $syslog = new Syslog(array(
41 | 'identity' => 'SyslogTest',
42 | 'priority' => LOG_DEBUG
43 | ));
44 | $expected = array(
45 | 'identity' => 'SyslogTest',
46 | 'options' => LOG_ODELAY,
47 | 'facility' => LOG_USER,
48 | 'priority' => LOG_DEBUG,
49 | 'init' => true
50 | );
51 | $result = $syslog->_config;
52 | $this->assertEqual($expected, $result);
53 | }
54 |
55 | public function testWrite() {
56 | $result = Logger::write('info', 'SyslogTest message...', array('name' => 'syslog'));
57 | $this->assertNotEmpty($result);
58 | }
59 | }
60 |
61 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/MockComment.php:
--------------------------------------------------------------------------------
1 | false, 'key' => 'comment_id');
20 |
21 | public static function find($type, array $options = array()) {
22 | $defaults = array(
23 | 'conditions' => null, 'fields' => null, 'order' => null, 'limit' => null, 'page' => 1
24 | );
25 | $options += $defaults;
26 | $params = compact('type', 'options');
27 | $self = static::_object();
28 |
29 | $filter = function($self, $params) {
30 | $query = new Query(array('type' => 'read') + $params['options']);
31 |
32 | return new RecordSet(array(
33 | 'query' => $query,
34 | 'data' => array_map(
35 | function($data) {
36 | return new Record(compact('data') + array('model' => __CLASS__));
37 | },
38 | array(
39 | array('comment_id' => 1, 'author_id' => 123, 'text' => 'First comment'),
40 | array('comment_id' => 2, 'author_id' => 241, 'text' => 'Second comment'),
41 | array('comment_id' => 3, 'author_id' => 451, 'text' => 'Third comment')
42 | )
43 | )
44 | ));
45 | };
46 | $finder = isset($self->_finders[$type]) ? array($self->_finders[$type]) : array();
47 | return static::_filter(__METHOD__, $params, $filter, $finder);
48 | }
49 | }
50 |
51 | ?>
--------------------------------------------------------------------------------
/tests/mocks/console/MockCommand.php:
--------------------------------------------------------------------------------
1 | 'lithium\tests\mocks\console\MockResponse'
41 | );
42 |
43 | public function testRun() {
44 | $this->response->testAction = __FUNCTION__;
45 | }
46 |
47 | public function clear() {}
48 |
49 | public function testReturnNull() {
50 | return null;
51 | }
52 |
53 | public function testReturnTrue() {
54 | return true;
55 | }
56 |
57 | public function testReturnFalse() {
58 | return false;
59 | }
60 |
61 | public function testReturnNegative1() {
62 | return -1;
63 | }
64 |
65 | public function testReturn1() {
66 | return 1;
67 | }
68 |
69 | public function testReturn3() {
70 | return 3;
71 | }
72 |
73 | public function testReturnString() {
74 | return 'this is a string';
75 | }
76 |
77 | public function testReturnEmptyArray() {
78 | return array();
79 | }
80 |
81 | public function testReturnArray() {
82 | return array('a' => 'b');
83 | }
84 | }
85 |
86 | ?>
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing guidelines
2 |
3 | Thank you for your interest in contributing to Lithium! This project is built by a thriving community of developers who value cutting-edge technology and concise, maintainable code. If you've found a bug, or have an idea for a feature, we encourage your participation in making Lithium better.
4 |
5 | Here's what you need to stick to in order to have the best chance of getting your code pushed to the core:
6 |
7 | * **Integration**: all pull requests should be submitted against the [`dev`](https://github.com/UnionOfRAD/lithium/tree/dev) branch for integration testing
8 | * **Branching**: create a short and meaningful branch name that starts with either `bug/` or `feature/`. A good example would be `feature/newMediaEncode` or `bug/modelFindFix`
9 | * **Conceptual integrity**: code should conform to the goals of the framework
10 | * **Maintainability**: code should pass existing [tests](https://github.com/UnionOfRAD/lithium/wiki/Spec%3A-Testing), have adequate test coverage and should conform to our [coding standards](https://github.com/UnionOfRAD/lithium/wiki/Spec%3A-Coding)
11 | * **Comprehensibility**: code should be concise and expressive, and should be accompanied by new [documentation](https://github.com/UnionOfRAD/lithium/wiki/Spec%3A-Documenting) as appropriate, or updates to existing docs
12 |
13 | As always, all contributions are important, and we're very grateful for the help of all those who have gotten us this far. If you're interested in helping out, but feel you could use a little coaching, be sure to drop by #li3-core and introduce yourself -- we'd love to help you get started.
14 |
15 | Please see the full documentation over at the [contribution guidelines](http://li3.me/docs/manual/appendices/contributing.wiki) at [li3.me](http://li3.me/)
16 |
--------------------------------------------------------------------------------
/tests/mocks/core/MockStaticMethodFiltering.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/data/source/mongo_db/Schema.php:
--------------------------------------------------------------------------------
1 | 'id',
23 | 'MongoDate' => 'date',
24 | 'MongoCode' => 'code',
25 | 'MongoBinData' => 'binary',
26 | 'datetime' => 'date',
27 | 'timestamp' => 'date',
28 | 'int' => 'integer'
29 | );
30 |
31 | public function __construct(array $config = array()) {
32 | $defaults = array('fields' => array('_id' => array('type' => 'id')));
33 | parent::__construct(array_filter($config) + $defaults);
34 | }
35 |
36 | protected function _init() {
37 | $this->_autoConfig[] = 'handlers';
38 | parent::_init();
39 |
40 | $this->_handlers += array(
41 | 'id' => function($v) {
42 | return is_string($v) && preg_match('/^[0-9a-f]{24}$/', $v) ? new MongoId($v) : $v;
43 | },
44 | 'date' => function($v) {
45 | $v = is_numeric($v) ? intval($v) : strtotime($v);
46 | return !$v ? new MongoDate() : new MongoDate($v);
47 | },
48 | 'regex' => function($v) { return new MongoRegex($v); },
49 | 'integer' => function($v) { return (integer) $v; },
50 | 'float' => function($v) { return (float) $v; },
51 | 'boolean' => function($v) { return (boolean) $v; },
52 | 'code' => function($v) { return new MongoCode($v); },
53 | 'binary' => function($v) { return new MongoBinData($v); }
54 | );
55 | }
56 | }
57 |
58 | ?>
--------------------------------------------------------------------------------
/tests/mocks/action/MockPostsController.php:
--------------------------------------------------------------------------------
1 | 'bar');
18 | }
19 | return 'List of posts';
20 | }
21 |
22 | public function delete($id = null) {
23 | if (empty($id)) {
24 | return $this->redirect('/posts', array('exit' => false));
25 | }
26 | return "Deleted {$id}";
27 | }
28 |
29 | public function send() {
30 | $this->redirect('/posts', array('exit' => true));
31 | }
32 |
33 | public function type($raw = false) {
34 | return array('data' => 'test');
35 | }
36 |
37 | public function notFound($id = null) {
38 | $this->response->status(404);
39 | $this->render(array('json' => $this->response->status));
40 | }
41 |
42 | public function view($id = null) {
43 | $this->render(array('text', 'data' => 'This is a post'));
44 | }
45 |
46 | public function view2($id = null) {
47 | $this->render(array('template' => 'view'));
48 | }
49 |
50 | public function view3($id = null) {
51 | $this->render(array('layout' => false, 'template' => 'view'));
52 | }
53 |
54 | public function changeTemplate() {
55 | $this->_render['template'] = 'foo';
56 | }
57 |
58 | protected function _safe() {
59 | throw new Exception('Something wrong happened');
60 | }
61 |
62 | public function access($var) {
63 | return $this->{$var};
64 | }
65 |
66 | protected function _stop($status = 0) {
67 | $this->stopped = true;
68 | }
69 | }
70 |
71 | ?>
--------------------------------------------------------------------------------
/tests/mocks/console/command/MockCommandHelp.php:
--------------------------------------------------------------------------------
1 | 'lithium\tests\mocks\console\MockResponse'
45 | );
46 |
47 | /**
48 | * This is the run command so don't show it.
49 | *
50 | * @return boolean
51 | */
52 | public function run() {
53 | return true;
54 | }
55 |
56 | /**
57 | * This is a task with required args.
58 | *
59 | * @param string $arg1
60 | * @param string $arg2
61 | * @return boolean
62 | */
63 | public function sampleTaskWithRequiredArgs($arg1, $arg2) {
64 | return true;
65 | }
66 |
67 | /**
68 | * This is a task with optional args.
69 | *
70 | * @param string $arg1
71 | * @param string $arg2
72 | * @return boolean
73 | */
74 | public function sampleTaskWithOptionalArgs($arg1 = null, $arg2 = null) {
75 | return true;
76 | }
77 |
78 | /**
79 | * Don't show in the help
80 | *
81 | * @return void
82 | */
83 | protected function _sampleHelper() {
84 |
85 | }
86 | }
87 |
88 | ?>
--------------------------------------------------------------------------------
/tests/integration/g11n/CatalogInflectorTest.php:
--------------------------------------------------------------------------------
1 | _backup['catalogConfig'] = Catalog::config();
21 | Catalog::config(array(
22 | 'runtime' => array('adapter' => new Memory())
23 | ));
24 | }
25 |
26 | public function tearDown() {
27 | Inflector::reset();
28 | Catalog::reset();
29 | Catalog::config($this->_backup['catalogConfig']);
30 | }
31 |
32 | public function testTransliteration() {
33 | $data = array(
34 | 'transliteration' => array(
35 | '\$' => 'dollar',
36 | '&' => 'and'
37 | )
38 | );
39 | Catalog::write('runtime', 'inflection', 'en', $data);
40 |
41 | Inflector::rules(
42 | 'transliteration', Catalog::read('runtime', 'inflection.transliteration', 'en')
43 | );
44 |
45 | $result = Inflector::slug('this & that');
46 | $expected = 'this-and-that';
47 | $this->assertEqual($expected, $result);
48 |
49 | $data = array(
50 | 'transliteration' => array(
51 | 't' => 'd',
52 | '&' => 'und'
53 | )
54 | );
55 | Catalog::write('runtime', 'inflection', 'de', $data);
56 |
57 | Inflector::rules(
58 | 'transliteration', Catalog::read('runtime', 'inflection.transliteration', 'de')
59 | );
60 |
61 | $result = Inflector::slug('this & that');
62 | $expected = 'dhis-und-dhad';
63 | $this->assertEqual($expected, $result);
64 | }
65 | }
66 |
67 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockDocumentPost.php:
--------------------------------------------------------------------------------
1 | false, 'initialized' => true, 'key' => '_id');
17 |
18 | public static function schema($field = null) {
19 | $schema = parent::schema();
20 | $schema->append(array(
21 | '_id' => array('type' => 'id'),
22 | 'foo' => array('type' => 'object'),
23 | 'foo.bar' => array('type' => 'int')
24 | ));
25 | return $schema;
26 | }
27 |
28 | public function ret($record, $param1 = null, $param2 = null) {
29 | if ($param2) {
30 | return $param2;
31 | }
32 | if ($param1) {
33 | return $param1;
34 | }
35 | return null;
36 | }
37 |
38 | public function medicin($record) {
39 | return 'lithium';
40 | }
41 |
42 | public static function find($type = 'all', array $options = array()) {
43 | switch ($type) {
44 | case 'first':
45 | return new Document(array(
46 | 'data' => array('_id' => 2, 'name' => 'Two', 'content' => 'Lorem ipsum two'),
47 | 'model' => __CLASS__
48 | ));
49 | break;
50 | case 'all':
51 | default:
52 | return new DocumentSet(array(
53 | 'data' => array(
54 | array('_id' => 1, 'name' => 'One', 'content' => 'Lorem ipsum one'),
55 | array('_id' => 2, 'name' => 'Two', 'content' => 'Lorem ipsum two'),
56 | array('_id' => 3, 'name' => 'Three', 'content' => 'Lorem ipsum three')
57 | ),
58 | 'model' => __CLASS__
59 | ));
60 | break;
61 | }
62 | }
63 | }
64 |
65 | ?>
--------------------------------------------------------------------------------
/tests/cases/console/command/create/ModelTest.php:
--------------------------------------------------------------------------------
1 | _testPath = Libraries::get(true, 'resources') . '/tmp/tests';
25 | $this->skipIf(!is_writable($this->_testPath), "Path `{$this->_testPath}` is not writable.");
26 | }
27 |
28 | public function setUp() {
29 | $this->classes = array('response' => 'lithium\tests\mocks\console\MockResponse');
30 | $this->_backup['cwd'] = getcwd();
31 | $this->_backup['_SERVER'] = $_SERVER;
32 | $_SERVER['argv'] = array();
33 |
34 | Libraries::add('create_test', array('path' => $this->_testPath . '/create_test'));
35 | $this->request = new Request(array('input' => fopen('php://temp', 'w+')));
36 | $this->request->params = array('library' => 'create_test');
37 | }
38 |
39 | public function tearDown() {
40 | $_SERVER = $this->_backup['_SERVER'];
41 | chdir($this->_backup['cwd']);
42 | $this->_cleanUp();
43 | }
44 |
45 | public function testClass() {
46 | $this->request->params = array(
47 | 'command' => 'model', 'action' => 'Posts'
48 | );
49 | $model = new Model(array(
50 | 'request' => $this->request, 'classes' => $this->classes
51 | ));
52 |
53 | $expected = 'Posts';
54 | $result = $model->invokeMethod('_class', array($this->request));
55 | $this->assertEqual($expected, $result);
56 | }
57 | }
58 |
59 | ?>
--------------------------------------------------------------------------------
/tests/integration/data/Base.php:
--------------------------------------------------------------------------------
1 | true);
23 | $this->_dbConfig = Connections::get($connection, array('config' => true));
24 | $db = $this->_db = Connections::get($connection);
25 |
26 | $this->skipIf(!$db, "The `'{$connection}' connection is not correctly configured`.");
27 | $this->skipIf(!$db::enabled(), 'Extension is not loaded.');
28 |
29 | $this->skipIf(!$db->isConnected($options), "No {$connection} connection available.");
30 | }
31 |
32 | public function with($adapters) {
33 | $adapters = (array) $adapters;
34 | $type = $this->_dbConfig['adapter'];
35 | $type = $type ?: $this->_dbConfig['type'];
36 | foreach ($adapters as $adapter) {
37 | if ($type === $adapter) {
38 | return true;
39 | }
40 | }
41 | return false;
42 | }
43 |
44 | public function skipIf($condition, $message = false) {
45 | if ($message === false) {
46 | $type = $this->_dbConfig['adapter'];
47 | $type = $type ?: $this->_dbConfig['type'];
48 | $class = basename(str_replace('\\', '/', get_called_class()));
49 | $callers = debug_backtrace();
50 | $caller = $callers[1]['function'];
51 | $method = $caller !== 'skip' ? "{$class}::" . $caller : $class;
52 | $message = "`{$method}` Not supported by the `'{$type}'` adapter";
53 | }
54 | return parent::skipIf($condition, $message);
55 | }
56 | }
57 |
58 | ?>
--------------------------------------------------------------------------------
/tests/cases/data/SourceTest.php:
--------------------------------------------------------------------------------
1 | false));
17 | $methods = $source->methods();
18 | $expected = array(
19 | 'connect', 'disconnect', 'sources', 'describe', 'create', 'read', 'update', 'delete',
20 | 'schema', 'result', 'cast', 'relationship', 'calculation', '__construct', '__destruct',
21 | '_init', 'isConnected', 'name', 'methods', 'configureClass', 'applyStrategy',
22 | 'applyFilter', 'invokeMethod', '__set_state', '_instance', '_filter', '_parents',
23 | '_stop'
24 | );
25 | $this->assertEqual(sort($expected), sort($methods));
26 | }
27 |
28 | public function testBaseMethods() {
29 | $source = new MockSource(array('autoConnect' => true));
30 | $name = '{(\'Li\':"∆")}';
31 | $this->assertEqual($name, $source->name($name));
32 |
33 | $expected = array(
34 | 'classes' => array(
35 | 'entity' => 'lithium\data\entity\Record',
36 | 'set' => 'lithium\data\collection\RecordSet',
37 | 'relationship' => 'lithium\data\model\Relationship',
38 | 'schema' => 'lithium\data\Schema'
39 | ),
40 | 'meta' => array('locked' => true, 'key' => 'id')
41 | );
42 | $this->assertEqual($expected, $source->configureClass('Foo'));
43 | }
44 |
45 | public function testConnection() {
46 | $source = new MockSource(array('autoConnect' => false));
47 | $this->assertFalse($source->isConnected());
48 | $this->assertTrue($source->isConnected(array('autoConnect' => true)));
49 | $this->assertTrue($source->isConnected());
50 | }
51 | }
52 |
53 | ?>
--------------------------------------------------------------------------------
/data/source/database/adapter/pdo/Result.php:
--------------------------------------------------------------------------------
1 | _resource instanceof PDOStatement) {
40 | try {
41 | $mode = $this->named ? PDO::FETCH_NAMED : PDO::FETCH_NUM;
42 | if ($result = $this->_resource->fetch($mode)) {
43 | $this->_key = $this->_iterator;
44 | $this->_current = $this->_cache[$this->_iterator++] = $result;
45 | return true;
46 | }
47 | } catch (PDOException $e) {}
48 | }
49 | $this->_resource = null;
50 | return false;
51 | }
52 |
53 | public function __destruct() {
54 | $this->close();
55 | }
56 | }
57 |
58 | ?>
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # The Lithium's Laboratory
2 |
3 | 
4 |
5 | [Lithium](http://lithify.me) is a fast, flexible and must have RAD development framework for PHP 5.3+. You can find more informations about this awesome framework on the [official github repository](https://github.com/UnionOfRAD/lithium).
6 |
7 | ## Do experiments, try, and merge !
8 |
9 | So this laboratory is essentially a place for chemists who want to manipulate atoms and looking for new awesome molecules for Lithium.
10 |
11 | **Before continuing, we must warn of the possible discovering of explosive molecules here**
12 |
13 | So to take full profits of researchs, an good knowledge of the Lithium core is greatly advisable.
14 |
15 | But like all experimental researchs, the discoveries may or may not be a part of Lithium, only depends on you. So modifications on methods names or inner logic can change once merged (if merged) on the official Lithium repository.
16 |
17 | ## You want in ?
18 |
19 | You are dreaming of something awesome for Lithium ? Don't wait anymore and post an issue right now !
20 |
21 | ## How to test ?
22 |
23 | We are experimenting a new framework app structure for building application. [Clone it](https://github.com/jails/li3_bigbang) and start the adventure !
24 |
25 | # Branches
26 |
27 | ## 0) The master branch
28 |
29 | The master branch is somehow a compilations of all patches. Don't expect to fetch any of this branches. They are all push forced to keep the maintenance simpler.
30 |
31 | ## 1) The patch/laboratory branch
32 |
33 | The current laboratory is currently focosed on the data abstract level. Works are done to bring the following feature:
34 | - HABTM support (using through implementation). --done--
35 | - Save all behavior. --done--
36 | - Mongo relations. --work in progress--
37 |
38 | #### Build status
39 |
40 | [](http://travis-ci.org/jails/lithium)
41 |
--------------------------------------------------------------------------------
/console/Router.php:
--------------------------------------------------------------------------------
1 | null, 'action' => 'run', 'args' => array());
29 | $params = $request ? (array) $request->params + $defaults : $defaults;
30 |
31 | if (!empty($request->argv)) {
32 | $args = $request->argv;
33 |
34 | while ($arg = array_shift($args)) {
35 | if (preg_match('/^-(?P[a-zA-Z0-9])$/i', $arg, $match)) {
36 | $params[$match['key']] = true;
37 | continue;
38 | }
39 | if (preg_match('/^--(?P[a-z0-9-]+)(?:=(?P.+))?$/i', $arg, $match)) {
40 | $params[$match['key']] = !isset($match['val']) ? true : $match['val'];
41 | continue;
42 | }
43 | $params['args'][] = $arg;
44 | }
45 | }
46 | foreach (array('command', 'action') as $param) {
47 | if (!empty($params['args'])) {
48 | $params[$param] = array_shift($params['args']);
49 | }
50 | }
51 | return $params;
52 | }
53 | }
54 |
55 | ?>
--------------------------------------------------------------------------------
/g11n/catalog/adapter/Memory.php:
--------------------------------------------------------------------------------
1 | _data[$scope][$category][$locale])) {
38 | return $this->_data[$scope][$category][$locale];
39 | }
40 | }
41 |
42 | /**
43 | * Writes data.
44 | *
45 | * @param string $category A category.
46 | * @param string $locale A locale identifier.
47 | * @param string $scope The scope for the current operation.
48 | * @param array $data The data to write.
49 | * @return boolean
50 | */
51 | public function write($category, $locale, $scope, array $data) {
52 | $scope = $scope ?: 'default';
53 |
54 | if (!isset($this->_data[$scope][$category][$locale])) {
55 | $this->_data[$scope][$category][$locale] = array();
56 | }
57 | foreach ($data as $item) {
58 | $this->_data[$scope][$category][$locale] = $this->_merge(
59 | $this->_data[$scope][$category][$locale],
60 | $this->_prepareForWrite($item)
61 | );
62 | }
63 | return true;
64 | }
65 | }
66 |
67 | ?>
--------------------------------------------------------------------------------
/console/command/create/Mock.php:
--------------------------------------------------------------------------------
1 | params['command'] = $request->action;
31 | return parent::_namespace($request, array('prepend' => 'tests.mocks.'));
32 | }
33 |
34 | /**
35 | * Get the parent for the mock.
36 | *
37 | * @param string $request
38 | * @return string
39 | */
40 | protected function _parent($request) {
41 | $namespace = parent::_namespace($request);
42 | $class = Inflector::camelize($request->action);
43 | return "\\{$namespace}\\{$class}";
44 | }
45 |
46 | /**
47 | * Get the class name for the mock.
48 | *
49 | * @param string $request
50 | * @return string
51 | */
52 | protected function _class($request) {
53 | $type = $request->action;
54 | $name = $request->args();
55 |
56 | if ($command = $this->_instance($type)) {
57 | $request->params['action'] = $name;
58 | $name = $command->invokeMethod('_class', array($request));
59 | }
60 | return "Mock{$name}";
61 | }
62 |
63 | /**
64 | * Get the methods for the mock to override
65 | *
66 | * @param string $request
67 | * @return string
68 | */
69 | protected function _methods($request) {
70 | return null;
71 | }
72 | }
73 |
74 | ?>
--------------------------------------------------------------------------------
/data/source/Mock.php:
--------------------------------------------------------------------------------
1 | 'lithium\data\Entity',
22 | 'set' => 'lithium\data\Collection',
23 | 'relationship' => 'lithium\data\model\Relationship',
24 | 'schema' => 'lithium\data\Schema'
25 | );
26 |
27 | public function connect() {
28 | return true;
29 | }
30 |
31 | public function disconnect() {
32 | return true;
33 | }
34 |
35 | public static function enabled($feature = null) {
36 | return false;
37 | }
38 |
39 | public function sources($class = null) {
40 | return array();
41 | }
42 |
43 | public function describe($entity, $fields = array(), array $meta = array()) {
44 | return $this->_instance('schema', compact('fields'));
45 | }
46 |
47 | public function relationship($class, $type, $name, array $options = array()) {
48 | return false;
49 | }
50 |
51 | public function create($query, array $options = array()) {
52 | return false;
53 | }
54 |
55 | public function read($query, array $options = array()) {
56 | return false;
57 | }
58 |
59 | public function update($query, array $options = array()) {
60 | return false;
61 | }
62 |
63 | public function delete($query, array $options = array()) {
64 | return false;
65 | }
66 | }
67 |
68 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/ImagesFixture.php:
--------------------------------------------------------------------------------
1 | array('type' => 'id'),
17 | 'gallery_id' => array('type' => 'integer', 'length' => 11),
18 | 'image' => array('type' => 'string', 'length' => 255),
19 | 'title' => array('type' => 'string', 'length' => 50),
20 | 'created' => array('type' => 'datetime'),
21 | 'modified' => array('type' => 'datetime')
22 | );
23 |
24 | protected $_records = array(
25 | array(
26 | 'id' => 1,
27 | 'gallery_id' => 1,
28 | 'image' => 'someimage.png',
29 | 'title' => 'Amiga 1200',
30 | 'created' => '2011-05-22 10:43:13',
31 | 'modified' => '2012-11-30 18:38:10'
32 | ),
33 | array(
34 | 'id' => 2,
35 | 'gallery_id' => 1,
36 | 'image' => 'image.jpg',
37 | 'title' => 'Srinivasa Ramanujan',
38 | 'created' => '2009-01-05 08:39:27',
39 | 'modified' => '2009-03-14 05:42:07'
40 | ),
41 | array(
42 | 'id' => 3,
43 | 'gallery_id' => 1,
44 | 'image' => 'photo.jpg',
45 | 'title' => 'Las Vegas',
46 | 'created' => '2010-08-11 23:12:03',
47 | 'modified' => '2010-09-24 04:45:14'
48 | ),
49 | array(
50 | 'id' => 4,
51 | 'gallery_id' => 2,
52 | 'image' => 'picture.jpg',
53 | 'title' => 'Silicon Valley',
54 | 'created' => '2008-08-22 17:55:10',
55 | 'modified' => '2008-08-22 17:55:10'
56 | ),
57 | array(
58 | 'id' => 5,
59 | 'gallery_id' => 2,
60 | 'image' => 'unknown.gif',
61 | 'title' => 'Unknown',
62 | 'created' => '2011-02-12 08:32:10',
63 | 'modified' => '2012-04-16 14:18:52'
64 | )
65 | );
66 | }
67 |
68 | ?>
--------------------------------------------------------------------------------
/tests/cases/analysis/logger/adapter/FileTest.php:
--------------------------------------------------------------------------------
1 | skipIf(!is_writable($path), "Path `{$path}` is not writable.");
22 | }
23 |
24 | public function setUp() {
25 | $this->path = Libraries::get(true, 'resources') . '/tmp/logs';
26 | $this->tearDown();
27 | }
28 |
29 | public function tearDown() {
30 | if (file_exists("{$this->path}/debug.log")) {
31 | unlink("{$this->path}/debug.log");
32 | }
33 | }
34 |
35 | public function testWriting() {
36 | $this->subject = new File(array('path' => $this->path));
37 | $priority = 'debug';
38 | $message = 'This is a debug message';
39 | $function = $this->subject->write($priority, $message);
40 | $now = date('Y-m-d H:i:s');
41 | $function('lithium\analysis\Logger', compact('priority', 'message'), new Filters());
42 |
43 | $log = file_get_contents("{$this->path}/debug.log");
44 | $this->assertEqual("{$now} This is a debug message\n", $log);
45 | }
46 |
47 | public function testWithoutTimestamp() {
48 | $this->subject = new File(array(
49 | 'path' => $this->path, 'timestamp' => false, 'format' => "{:message}\n"
50 | ));
51 | $priority = 'debug';
52 | $message = 'This is a debug message';
53 | $function = $this->subject->write($priority, $message);
54 | $now = date('Y-m-d H:i:s');
55 | $function('lithium\analysis\Logger', compact('priority', 'message'), new Filters());
56 |
57 | $log = file_get_contents("{$this->path}/debug.log");
58 | $this->assertEqual("This is a debug message\n", $log);
59 | }
60 | }
61 |
62 | ?>
--------------------------------------------------------------------------------
/tests/fixture/model/gallery/export/testSaveNested.php:
--------------------------------------------------------------------------------
1 | array (
4 | 'id' => '1',
5 | 'name' => 'Foo Gallery',
6 | 'active' => '1',
7 | 'created' => NULL,
8 | 'modified' => NULL,
9 | 'images' => array (
10 | 1 => array (
11 | 'id' => '1',
12 | 'gallery_id' => '1',
13 | 'image' => 'someimage.png',
14 | 'title' => 'Image1 Title',
15 | 'created' => NULL,
16 | 'modified' => NULL,
17 | 'images_tags' => array (
18 | 1 => array (
19 | 'id' => '1',
20 | 'image_id' => '1',
21 | 'tag_id' => '1',
22 | ),
23 | 2 => array (
24 | 'id' => '2',
25 | 'image_id' => '1',
26 | 'tag_id' => '2',
27 | ),
28 | 3 => array (
29 | 'id' => '3',
30 | 'image_id' => '1',
31 | 'tag_id' => '3',
32 | ),
33 | ),
34 | 'tags' => array (
35 | 1 => array (
36 | 'id' => '1',
37 | 'name' => 'tag1'
38 | ),
39 | 2 => array (
40 | 'id' => '2',
41 | 'name' => 'tag2'
42 | ),
43 | 3 => array (
44 | 'id' => '3',
45 | 'name' => 'tag3'
46 | ),
47 | ),
48 | ),
49 | 2 => array (
50 | 'id' => '2',
51 | 'gallery_id' => '1',
52 | 'image' => 'anotherImage.jpg',
53 | 'title' => 'Our Vacation',
54 | 'created' => NULL,
55 | 'modified' => NULL,
56 | 'images_tags' => array (
57 | 4 => array (
58 | 'id' => '4',
59 | 'image_id' => '2',
60 | 'tag_id' => '4',
61 | ),
62 | 5 => array (
63 | 'id' => '5',
64 | 'image_id' => '2',
65 | 'tag_id' => '5',
66 | ),
67 | ),
68 | 'tags' => array (
69 | 4 => array (
70 | 'id' => '4',
71 | 'name' => 'tag4'
72 | ),
73 | 5 => array (
74 | 'id' => '5',
75 | 'name' => 'tag5'
76 | ),
77 | ),
78 | ),
79 | 3 => array (
80 | 'id' => '3',
81 | 'gallery_id' => '1',
82 | 'image' => 'me.bmp',
83 | 'title' => 'Me.',
84 | 'created' => NULL,
85 | 'modified' => NULL,
86 | 'images_tags' => array (
87 | ),
88 | 'tags' => array (
89 | ),
90 | ),
91 | ),
92 | ),
93 | );
94 | ?>
--------------------------------------------------------------------------------
/test/templates/coverage.txt.php:
--------------------------------------------------------------------------------
1 | {:heading}Code Coverage{:end}
2 | 0, 'executable' => 0, 'covered' => 0, 'uncovered' => 0, 'percentage' => 0
6 | );
7 |
8 | $colorMap = array(
9 | 'ignored' => 'white',
10 | 'covered' => 'success',
11 | 'uncovered' => 'error',
12 | );
13 |
14 | foreach ($data as $class => $coverage) {
15 | $summary['classes']++;
16 | $summary['executable'] += count($coverage['executable']);
17 | $summary['covered'] += count($coverage['covered']);
18 | $summary['uncovered'] += count($coverage['uncovered']);
19 | $summary['percentage'] += $coverage['percentage'];
20 |
21 | echo ($coverage['percentage'] >= 85 ? "{:success}" : "{:error}");
22 | echo "{$class}{:end}: ";
23 | echo count($coverage['covered']) . " of " . count($coverage['executable']);
24 | echo " lines covered (";
25 | echo ($coverage['percentage'] >= 85 ? "{:success}" : "{:error}");
26 | echo "{$coverage['percentage']}%{:end})\n";
27 |
28 | if ($coverage['percentage'] == 100) {
29 | continue;
30 | }
31 | echo "\n{:heading}Coverage analysis{:end}\n";
32 |
33 | foreach ($coverage['output'] as $file => $lines) {
34 | echo "\n{$file}:\n";
35 |
36 | foreach ($lines as $num => $line) {
37 | $color = $colorMap[$line['class']];
38 | echo "{:{$color}}{$num} {$line['data']}{:end}\n";
39 | }
40 | }
41 | echo "\n";
42 | }
43 |
44 | $displayPercentage = function($raw) {
45 | $percentage = round($raw);
46 | echo ($percentage > 70) ? "{:success}" : "{:error}";
47 | echo "$percentage{:end}";
48 | };
49 | ?>
50 |
51 | {:heading}Summary{:end}
52 |
53 | Classes Covered:
54 |
55 | Executable Lines:
56 |
57 | Lines Covered:
58 |
59 | Lines Uncovered:
60 |
61 | Total Coverage: %
65 | Average Per Class: %
69 |
--------------------------------------------------------------------------------
/tests/mocks/data/model/MockDocumentSource.php:
--------------------------------------------------------------------------------
1 | 'lithium\data\entity\Document',
15 | 'set' => 'lithium\data\collection\DocumentSet',
16 | 'relationship' => 'lithium\data\model\Relationship',
17 | 'schema' => 'lithium\data\source\mongo_db\Schema'
18 | );
19 |
20 | public function connect() {}
21 | public function disconnect() {}
22 | public function sources($class = null) {}
23 | public function describe($entity, $schema = array(), array $meta = array()) {
24 | return $this->_instance('schema');
25 | }
26 | public function create($query, array $options = array()) {}
27 | public function update($query, array $options = array()) {}
28 | public function delete($query, array $options = array()) {}
29 |
30 | public $point = 0;
31 | public $result = null;
32 |
33 | public function read($query = null, array $options = array()) {
34 | $this->point = 0;
35 | $this->result = array(
36 | array('id' => 1, 'name' => 'Joe'),
37 | array('id' => 2, 'name' => 'Moe'),
38 | array('id' => 3, 'name' => 'Roe')
39 | );
40 | }
41 |
42 | public function getNext() {
43 | return $this->result[$this->point++];
44 | }
45 |
46 | public function result($type, $resource, $context) {
47 | switch ($type) {
48 | case 'next':
49 | $result = $resource->hasNext() ? $resource->getNext() : null;
50 | break;
51 | case 'close':
52 | unset($resource);
53 | $result = null;
54 | break;
55 | }
56 | return $result;
57 | }
58 |
59 | public function relationship($class, $type, $name, array $options = array()) {
60 | $key = Inflector::camelize($type === 'belongsTo' ? $name : $class::meta('name'));
61 |
62 | $options += compact('name', 'type', 'key');
63 | $options['from'] = $class;
64 |
65 | $relationship = $this->_classes['relationship'];
66 | return new $relationship($options);
67 | }
68 | }
69 |
70 | ?>
--------------------------------------------------------------------------------
/tests/mocks/data/source/mongo_db/MockResult.php:
--------------------------------------------------------------------------------
1 | '4c8f86167675abfabdbf0300', 'title' => 'bar'),
15 | array('_id' => '5c8f86167675abfabdbf0301', 'title' => 'foo'),
16 | array('_id' => '6c8f86167675abfabdbf0302', 'title' => 'dib')
17 | );
18 |
19 | protected $_init = false;
20 |
21 | protected $_autoConfig = array('data', 'name');
22 |
23 | protected $_name = '';
24 |
25 | public $query = array();
26 |
27 | public function hasNext() {
28 | return ($this->_iterator < count($this->_data));
29 | }
30 |
31 | public function getNext() {
32 | $this->_fetchFromResource();
33 | return $this->_current;
34 | }
35 |
36 | /**
37 | * Fetches the result from the resource and caches it.
38 | *
39 | * @return boolean Return `true` on success or `false` if it is not valid.
40 | */
41 | protected function _fetchFromResource() {
42 | if ($this->_iterator < count($this->_data)) {
43 | $result = current($this->_data);
44 | $this->_key = $this->_iterator;
45 | $this->_current = $this->_cache[$this->_iterator++] = $result;
46 | next($this->_data);
47 | return true;
48 | }
49 | return false;
50 | }
51 |
52 | public function getName() {
53 | return $this->_name;
54 | }
55 |
56 | protected function _close() {
57 | }
58 |
59 | public function fields(array $fields = array()) {
60 | $this->query[__FUNCTION__] = $fields;
61 | return $this;
62 | }
63 |
64 | public function limit($num) {
65 | $this->query[__FUNCTION__] = $num;
66 | return $this;
67 | }
68 |
69 | public function skip($num) {
70 | $this->query[__FUNCTION__] = $num;
71 | return $this;
72 | }
73 |
74 | public function sort(array $fields = array()) {
75 | $this->query[__FUNCTION__] = $fields;
76 | return $this;
77 | }
78 |
79 | public function count() {
80 | return reset($this->_data);
81 | }
82 | }
83 |
84 | ?>
--------------------------------------------------------------------------------
/tests/cases/security/validation/FormSignatureTest.php:
--------------------------------------------------------------------------------
1 | array(
29 | 'email' => 'foo@baz',
30 | 'pass' => 'whatever',
31 | 'active' => 'true',
32 | 'security' => compact('signature')
33 | )));
34 | $this->assertTrue(FormSignature::check($request));
35 |
36 | $request = new Request(array('data' => array(
37 | 'email' => 'foo@baz',
38 | 'pass' => 'whatever',
39 | 'active' => 'false',
40 | 'security' => compact('signature')
41 | )));
42 | $this->assertFalse(FormSignature::check($request));
43 | }
44 |
45 | /**
46 | * Tests that `FormSignature` correctly ignores other fields in the `'security'` array when
47 | * generating signatures.
48 | */
49 | public function testIgnoreSecurityFields() {
50 | $components = array(
51 | 'a%3A1%3A%7Bs%3A6%3A%22active%22%3Bs%3A4%3A%22true%22%3B%7D',
52 | 'a%3A0%3A%7B%7D',
53 | '$2a$10$NuNTOeXv4OHpPJtbdAmfReFiSmFw5hmc6sSy8qwns6/DWNSSOjR1y'
54 | );
55 | $signature = join('::', $components);
56 |
57 | $request = new Request(array('data' => array(
58 | 'email' => 'foo@baz',
59 | 'pass' => 'whatever',
60 | 'active' => 'true',
61 | 'security' => compact('signature') + array('foo' => 'bar')
62 | )));
63 | $this->assertTrue(FormSignature::check($request));
64 | }
65 | }
66 |
67 | ?>
68 |
--------------------------------------------------------------------------------
/tests/mocks/data/source/MockMongoConnection.php:
--------------------------------------------------------------------------------
1 | _collection = $property;
29 | return $this;
30 | }
31 |
32 | public function listDBs() {
33 | return array();
34 | }
35 |
36 | public function getConnections() {
37 | return array(array(
38 | 'hash' => 'localhost:27017;-;X;56052',
39 | 'server' => array(),
40 | 'connection' => array()
41 | ));
42 | }
43 |
44 | public function insert(array &$data, array $options = array()) {
45 | $data['_id'] = new MongoId();
46 | return $this->_record(__FUNCTION__, compact('data', 'options'));
47 | }
48 |
49 | protected function _record($type, array $data = array()) {
50 | $collection = $this->_collection;
51 | $this->queries[] = compact('type', 'collection') + $data;
52 | $result = array_pop($this->results);
53 | return $result === null ? false : $result;
54 | }
55 |
56 | public function update($conditions, $update, $options) {
57 | return $this->_record(__FUNCTION__, compact('conditions', 'update', 'options'));
58 | }
59 |
60 | public function remove($conditions, $options) {
61 | return $this->_record(__FUNCTION__, compact('conditions', 'options'));
62 | }
63 |
64 | public function find($conditions, $fields) {
65 | return $this->_record(__FUNCTION__, compact('conditions', 'fields'));
66 | }
67 |
68 | public function listCollections() {
69 | return $this->_record(__FUNCTION__);
70 | }
71 |
72 | public function getGridFS($prefix = "fs") {
73 | $this->gridFsPrefix = $prefix;
74 | return $this;
75 | }
76 |
77 | public function storeBytes($bytes = null, array $extra = array(), array $options = array()) {
78 | return;
79 | }
80 | }
81 |
82 | ?>
--------------------------------------------------------------------------------
/tests/integration/data/DocumentTest.php:
--------------------------------------------------------------------------------
1 | _connection);
20 | $this->skipIf(!$this->with(array('MongoDb', 'CouchDb')));
21 | }
22 |
23 | public function setUp() {
24 | Galleries::config(array('meta' => array('connection' => 'test')));
25 | }
26 |
27 | public function tearDown() {
28 | Galleries::remove();
29 | Galleries::reset();
30 | }
31 |
32 | /**
33 | * Tests that a successful find on an empty collection doesn't error out
34 | * when using count on the resulting collection returned. See issue #1042.
35 | */
36 | public function testFindOnEmptyCollection() {
37 | $result = Galleries::find('all');
38 |
39 | $expected = 0;
40 | $result = $result->count();
41 | $this->assertIdentical($expected, $result);
42 | }
43 |
44 | public function testUpdateWithNewArray() {
45 | $new = Galleries::create(array('name' => 'Poneys', 'active' => true));
46 |
47 | $expected = array('name' => 'Poneys', 'active' => true);
48 | $result = $new->data();
49 | $this->assertEqual($expected, $result);
50 |
51 | $new->foo = array('bar');
52 | $expected = array('name' => 'Poneys', 'active' => true, 'foo' => array('bar'));
53 | $result = $new->data();
54 | $this->assertEqual($expected, $result);
55 |
56 | $this->assertTrue($new->save());
57 |
58 | $updated = Galleries::find((string) $new->_id);
59 | $expected = 'bar';
60 | $result = $updated->foo[0];
61 | $this->assertEqual($expected, $result);
62 |
63 | $updated->foo[1] = 'baz';
64 |
65 | $this->assertTrue($updated->save());
66 |
67 | $updated = Galleries::find((string) $updated->_id);
68 | $expected = 'baz';
69 | $result = $updated->foo[1];
70 | $this->assertEqual($expected, $result);
71 | }
72 | }
73 |
74 | ?>
--------------------------------------------------------------------------------
/tests/cases/analysis/logger/adapter/CacheTest.php:
--------------------------------------------------------------------------------
1 | array(
26 | 'adapter' => 'Memory'
27 | )
28 | ));
29 | $this->cachelog = new Cache(array(
30 | 'key' => 'cachelog_testkey',
31 | 'config' => 'cachelog'
32 | ));
33 | Logger::config(array(
34 | 'cachelog' => array(
35 | 'adapter' => $this->cachelog,
36 | 'key' => 'cachelog_testkey',
37 | 'config' => 'cachelog'
38 | )
39 | ));
40 | }
41 |
42 | /**
43 | * Test the initialization of the cache log adapter.
44 | */
45 | public function testConstruct() {
46 | $expected = array(
47 | 'config' => "cachelog",
48 | 'expiry' => CacheStorage::PERSIST,
49 | 'key' => "cachelog_testkey",
50 | 'init' => true
51 | );
52 | $result = $this->cachelog->_config;
53 | $this->assertEqual($expected, $result);
54 | }
55 |
56 | /**
57 | * Test if the configuration is correctly set in the logger.
58 | */
59 | public function testConfiguration() {
60 | $loggers = Logger::config();
61 | $this->assertArrayHasKey('cachelog', $loggers);
62 | }
63 |
64 | /**
65 | * Tests the correct writing to the cache adapter. In this test we use the
66 | * "Memory" cache adapter so that we can easily verify the written message.
67 | */
68 | public function testWrite() {
69 | $message = "CacheLog test message...";
70 | $result = Logger::write('info', $message, array('name' => 'cachelog'));
71 | $this->assertNotEmpty($result);
72 | $result = CacheStorage::read('cachelog', 'cachelog_testkey');
73 | $this->assertEqual($message, $result);
74 | }
75 | }
76 |
77 | ?>
--------------------------------------------------------------------------------
/console/command/create/Controller.php:
--------------------------------------------------------------------------------
1 | params['command'] = 'model';
30 | return $this->_namespace($request) . '\\' . $this->_model($request);
31 | }
32 |
33 | /**
34 | * Get the controller class name.
35 | *
36 | * @param string $request
37 | * @return string
38 | */
39 | protected function _class($request) {
40 | return $this->_name($request) . 'Controller';
41 | }
42 |
43 | /**
44 | * Returns the name of the controller class, minus `'Controller'`.
45 | *
46 | * @param string $request
47 | * @return string
48 | */
49 | protected function _name($request) {
50 | return Inflector::camelize($request->action);
51 | }
52 |
53 | /**
54 | * Get the plural variable used for data in controller methods.
55 | *
56 | * @param string $request
57 | * @return string
58 | */
59 | protected function _plural($request) {
60 | return Inflector::pluralize(Inflector::camelize($request->action, false));
61 | }
62 |
63 | /**
64 | * Get the model class used in controller methods.
65 | *
66 | * @param string $request
67 | * @return string
68 | */
69 | protected function _model($request) {
70 | return Inflector::camelize($request->action);
71 | }
72 |
73 | /**
74 | * Get the singular variable to use for data in controller methods.
75 | *
76 | * @param string $request
77 | * @return string
78 | */
79 | protected function _singular($request) {
80 | return Inflector::singularize(Inflector::camelize($request->action, false));
81 | }
82 | }
83 |
84 | ?>
--------------------------------------------------------------------------------
/template/view/adapter/Simple.php:
--------------------------------------------------------------------------------
1 | array());
33 | $options += $defaults;
34 |
35 | $context = array();
36 | $this->_context = $options['context'] + $this->_context;
37 |
38 | foreach (array_keys($this->_context) as $key) {
39 | $context[$key] = $this->__get($key);
40 | }
41 | $data = array_merge($this->_toString($context), $this->_toString($data));
42 | return String::insert($template, $data, $options);
43 | }
44 |
45 | /**
46 | * Returns a template string
47 | *
48 | * @param string $type
49 | * @param array $options
50 | * @return string
51 | */
52 | public function template($type, $options) {
53 | if (isset($options[$type])) {
54 | return $options[$type];
55 | }
56 | return isset($options['template']) ? $options['template'] : '';
57 | }
58 |
59 | /**
60 | * Renders `$data` into an easier to understand, or flat, array.
61 | *
62 | * @param array $data Data to traverse.
63 | * @return array
64 | */
65 | protected function _toString($data) {
66 | foreach ($data as $key => $val) {
67 | switch (true) {
68 | case is_object($val) && !$val instanceof Closure:
69 | try {
70 | $data[$key] = (string) $val;
71 | } catch (Exception $e) {
72 | $data[$key] = '';
73 | }
74 | break;
75 | case is_array($val):
76 | $data = array_merge($data, Set::flatten($val));
77 | break;
78 | }
79 | }
80 | return $data;
81 | }
82 | }
83 |
84 | ?>
--------------------------------------------------------------------------------
/tests/integration/g11n/CatalogValidatorTest.php:
--------------------------------------------------------------------------------
1 | _backup['catalogConfig'] = Catalog::config();
21 | Catalog::config(array(
22 | 'runtime' => array('adapter' => new Memory())
23 | ));
24 | }
25 |
26 | public function tearDown() {
27 | Catalog::reset();
28 | Validator::reset();
29 | Catalog::config($this->_backup['catalogConfig']);
30 | }
31 |
32 | public function testFlat() {
33 | $data = '/postalCode en_US/';
34 | Catalog::write('runtime', 'validation.postalCode', 'en_US', $data);
35 |
36 | Validator::add('postalCode', Catalog::read('runtime', 'validation.postalCode', 'en_US'));
37 |
38 | $result = Validator::isPostalCode('postalCode en_US');
39 | $this->assertTrue($result);
40 | }
41 |
42 | public function testMultipleRules() {
43 | $data = array(
44 | 'postalCode' => '/postalCode en_US/',
45 | 'phone' => '/phone en_US/'
46 | );
47 | Catalog::write('runtime', 'validation', 'en_US', $data);
48 |
49 | Validator::add(Catalog::read('runtime', 'validation', 'en_US'));
50 |
51 | $result = Validator::isPostalCode('postalCode en_US');
52 | $this->assertTrue($result);
53 |
54 | $result = Validator::isPhone('phone en_US');
55 | $this->assertTrue($result);
56 | }
57 |
58 | public function testMultipleLocales() {
59 | $data = '/phone en_US/';
60 | Catalog::write('runtime', 'validation.phone', 'en_US', $data);
61 | $data = '/phone en_GB/';
62 | Catalog::write('runtime', 'validation.phone', 'en_GB', $data);
63 |
64 | Validator::add('phone', array(
65 | 'en_US' => Catalog::read('runtime', 'validation.phone', 'en_US'),
66 | 'en_GB' => Catalog::read('runtime', 'validation.phone', 'en_GB')
67 | ));
68 |
69 | $result = Validator::isPhone('phone en_US', 'en_US');
70 | $this->assertTrue($result);
71 |
72 | $result = Validator::isPhone('phone en_GB', 'en_GB');
73 | $this->assertTrue($result);
74 | }
75 | }
76 |
77 | ?>
--------------------------------------------------------------------------------