@@ -121,17 +121,14 @@ public function testListAllConnection() {
121
121
* @return void
122
122
*/
123
123
public function testGetTable () {
124
- $ this ->Task ->args [0 ] = 'BakeArticle ' ;
125
- $ result = $ this ->Task ->getTable ();
124
+ $ result = $ this ->Task ->getTable ('BakeArticle ' );
126
125
$ this ->assertEquals ('bake_articles ' , $ result );
127
126
128
- $ this ->Task ->args [0 ] = 'BakeArticles ' ;
129
- $ result = $ this ->Task ->getTable ();
127
+ $ result = $ this ->Task ->getTable ('BakeArticles ' );
130
128
$ this ->assertEquals ('bake_articles ' , $ result );
131
129
132
- $ this ->Task ->args [0 ] = 'Article ' ;
133
130
$ this ->Task ->params ['table ' ] = 'bake_articles ' ;
134
- $ result = $ this ->Task ->getTable ();
131
+ $ result = $ this ->Task ->getTable (' Article ' );
135
132
$ this ->assertEquals ('bake_articles ' , $ result );
136
133
}
137
134
@@ -673,164 +670,69 @@ public function testExecuteWithNamedModelVariations($name) {
673
670
* @return void
674
671
*/
675
672
public function testExecuteIntoAll () {
676
- $ this ->markTestIncomplete ('Not done here yet ' );
677
- $ count = count ($ this ->Task ->listAll ('test ' ));
673
+ $ count = count ($ this ->Task ->listAll ());
678
674
if ($ count != count ($ this ->fixtures )) {
679
675
$ this ->markTestSkipped ('Additional tables detected. ' );
680
676
}
681
677
682
678
$ this ->Task ->connection = 'test ' ;
683
679
$ this ->Task ->path = '/my/path/ ' ;
684
- $ this ->Task ->args = array ('all ' );
685
- $ this ->Task ->expects ($ this ->once ())->method ('_checkUnitTest ' )->will ($ this ->returnValue (true ));
686
-
687
- $ this ->Task ->Fixture ->expects ($ this ->exactly (5 ))->method ('bake ' );
688
- $ this ->Task ->Test ->expects ($ this ->exactly (5 ))->method ('bake ' );
689
-
690
- $ filename = '/my/path/BakeArticle.php ' ;
691
- $ this ->Task ->expects ($ this ->at (1 ))->method ('createFile ' )
692
- ->with ($ filename , $ this ->stringContains ('class BakeArticle ' ));
693
-
694
- $ filename = '/my/path/BakeArticlesBakeTag.php ' ;
695
- $ this ->Task ->expects ($ this ->at (2 ))->method ('createFile ' )
696
- ->with ($ filename , $ this ->stringContains ('class BakeArticlesBakeTag ' ));
697
-
698
- $ filename = '/my/path/BakeComment.php ' ;
699
- $ this ->Task ->expects ($ this ->at (3 ))->method ('createFile ' )
700
- ->with ($ filename , $ this ->stringContains ('class BakeComment ' ));
701
-
702
- $ filename = '/my/path/BakeComment.php ' ;
703
- $ this ->Task ->expects ($ this ->at (3 ))->method ('createFile ' )
704
- ->with ($ filename , $ this ->stringContains ('public $primaryKey = \'otherid \'; ' ));
705
-
706
- $ filename = '/my/path/BakeTag.php ' ;
707
- $ this ->Task ->expects ($ this ->at (4 ))->method ('createFile ' )
708
- ->with ($ filename , $ this ->stringContains ('class BakeTag ' ));
709
-
710
- $ filename = '/my/path/BakeTag.php ' ;
711
- $ this ->Task ->expects ($ this ->at (4 ))->method ('createFile ' )
712
- ->with ($ filename , $ this ->logicalNot ($ this ->stringContains ('public $primaryKey ' )));
713
-
714
- $ filename = '/my/path/CategoryThread.php ' ;
715
- $ this ->Task ->expects ($ this ->at (5 ))->method ('createFile ' )
716
- ->with ($ filename , $ this ->stringContains ('class CategoryThread ' ));
717
-
718
- $ this ->Task ->execute ();
719
-
720
- $ this ->assertEquals (count (ClassRegistry::keys ()), 0 );
721
- $ this ->assertEquals (count (ClassRegistry::mapKeys ()), 0 );
722
- }
723
-
724
- /**
725
- * test that odd tablenames aren't inflected back from modelname
726
- *
727
- * @return void
728
- */
729
- public function testExecuteIntoAllOddTables () {
730
- $ this ->markTestIncomplete ('Not done here yet ' );
731
- $ out = $ this ->getMock ('Cake\Console\ConsoleOutput ' , array (), array (), '' , false );
732
- $ in = $ this ->getMock ('Cake\Console\ConsoleInput ' , array (), array (), '' , false );
733
- $ this ->Task = $ this ->getMock ('Cake\Console\Command\Task\ModelTask ' ,
734
- array ('in ' , 'err ' , '_stop ' , '_checkUnitTest ' , 'getAllTables ' , '_getModelObject ' , 'bake ' , 'bakeFixture ' ),
735
- array ($ out , $ out , $ in )
736
- );
737
- $ this ->_setupOtherMocks ();
738
-
739
- $ this ->Task ->connection = 'test ' ;
740
- $ this ->Task ->path = '/my/path/ ' ;
741
- $ this ->Task ->args = array ('all ' );
742
- $ this ->Task ->expects ($ this ->once ())->method ('_checkUnitTest ' )->will ($ this ->returnValue (true ));
743
- $ this ->Task ->expects ($ this ->once ())->method ('getAllTables ' )->will ($ this ->returnValue (array ('bake_odd ' )));
744
- $ object = new Model (array ('name ' => 'BakeOdd ' , 'table ' => 'bake_odd ' , 'ds ' => 'test ' ));
745
- $ this ->Task ->expects ($ this ->once ())->method ('_getModelObject ' )->with ('BakeOdd ' , 'bake_odd ' )->will ($ this ->returnValue ($ object ));
746
- $ this ->Task ->expects ($ this ->at (3 ))->method ('bake ' )->with ($ object , false )->will ($ this ->returnValue (true ));
747
- $ this ->Task ->expects ($ this ->once ())->method ('bakeFixture ' )->with ('BakeOdd ' , 'bake_odd ' );
680
+ $ this ->Task ->args = ['all ' ];
748
681
749
- $ this ->Task ->execute ();
682
+ $ this ->Task ->Fixture ->expects ($ this ->exactly (6 ))
683
+ ->method ('bake ' );
684
+ $ this ->Task ->Test ->expects ($ this ->exactly (6 ))
685
+ ->method ('bake ' );
750
686
751
- $ out = $ this ->getMock ('ConsoleOutput ' , array (), array (), '' , false );
752
- $ in = $ this ->getMock ('ConsoleInput ' , array (), array (), '' , false );
753
- $ this ->Task = $ this ->getMock ('ModelTask ' ,
754
- array ('in ' , 'err ' , '_stop ' , '_checkUnitTest ' , 'getAllTables ' , '_getModelObject ' , 'doAssociations ' , 'doValidation ' , 'doActsAs ' , 'createFile ' ),
755
- array ($ out , $ out , $ in )
756
- );
757
- $ this ->_setupOtherMocks ();
687
+ $ filename = '/my/path/Table/BakeArticlesTable.php ' ;
688
+ $ this ->Task ->expects ($ this ->at (0 ))
689
+ ->method ('createFile ' )
690
+ ->with ($ filename , $ this ->stringContains ('class BakeArticlesTable extends ' ));
758
691
759
- $ this ->Task ->connection = 'test ' ;
760
- $ this ->Task ->path = '/my/path/ ' ;
761
- $ this ->Task ->args = array ('all ' );
762
- $ this ->Task ->expects ($ this ->once ())->method ('_checkUnitTest ' )->will ($ this ->returnValue (true ));
763
- $ this ->Task ->expects ($ this ->once ())->method ('getAllTables ' )->will ($ this ->returnValue (array ('bake_odd ' )));
764
- $ object = new Model (array ('name ' => 'BakeOdd ' , 'table ' => 'bake_odd ' , 'ds ' => 'test ' ));
765
- $ this ->Task ->expects ($ this ->once ())->method ('_getModelObject ' )->will ($ this ->returnValue ($ object ));
766
- $ this ->Task ->expects ($ this ->once ())->method ('doAssociations ' )->will ($ this ->returnValue (array ()));
767
- $ this ->Task ->expects ($ this ->once ())->method ('doValidation ' )->will ($ this ->returnValue (array ()));
768
- $ this ->Task ->expects ($ this ->once ())->method ('doActsAs ' )->will ($ this ->returnValue (array ()));
769
-
770
- $ filename = '/my/path/BakeOdd.php ' ;
771
- $ this ->Task ->expects ($ this ->once ())->method ('createFile ' )
772
- ->with ($ filename , $ this ->stringContains ('class BakeOdd ' ));
692
+ $ filename = '/my/path/Entity/BakeArticle.php ' ;
693
+ $ this ->Task ->expects ($ this ->at (1 ))
694
+ ->method ('createFile ' )
695
+ ->with ($ filename , $ this ->stringContains ('class BakeArticle extends ' ));
773
696
774
- $ filename = '/my/path/BakeOdd.php ' ;
775
- $ this ->Task ->expects ($ this ->once ())->method ('createFile ' )
776
- ->with ($ filename , $ this ->stringContains ('public $useTable = \'bake_odd \'' ));
697
+ $ filename = '/my/path/Table/BakeArticlesBakeTagsTable.php ' ;
698
+ $ this ->Task ->expects ($ this ->at (2 ))
699
+ ->method ('createFile ' )
700
+ ->with ($ filename , $ this ->stringContains ('class BakeArticlesBakeTagsTable extends ' ));
777
701
778
- $ this ->Task ->execute ();
779
- }
702
+ $ filename = '/my/path/Entity/BakeArticlesBakeTag.php ' ;
703
+ $ this ->Task ->expects ($ this ->at (3 ))
704
+ ->method ('createFile ' )
705
+ ->with ($ filename , $ this ->stringContains ('class BakeArticlesBakeTag extends ' ));
780
706
781
- /**
782
- * test that odd tablenames aren't inflected back from modelname
783
- *
784
- * @return void
785
- */
786
- public function testExecuteIntoBakeOddTables () {
787
- $ this ->markTestIncomplete ('Not done here yet ' );
788
- $ out = $ this ->getMock ('Cake\Console\ConsoleOutput ' , array (), array (), '' , false );
789
- $ in = $ this ->getMock ('Cake\Console\ConsoleInput ' , array (), array (), '' , false );
790
- $ this ->Task = $ this ->getMock ('Cake\Console\Command\Task\ModelTask ' ,
791
- array ('in ' , 'err ' , '_stop ' , '_checkUnitTest ' , 'getAllTables ' , '_getModelObject ' , 'bake ' , 'bakeFixture ' ),
792
- array ($ out , $ out , $ in )
793
- );
794
- $ this ->_setupOtherMocks ();
707
+ $ filename = '/my/path/Table/BakeCommentsTable.php ' ;
708
+ $ this ->Task ->expects ($ this ->at (4 ))
709
+ ->method ('createFile ' )
710
+ ->with ($ filename , $ this ->stringContains ('class BakeCommentsTable extends ' ));
795
711
796
- $ this ->Task ->connection = 'test ' ;
797
- $ this ->Task ->path = '/my/path/ ' ;
798
- $ this ->Task ->args = array ('BakeOdd ' );
799
- $ this ->Task ->expects ($ this ->once ())->method ('_checkUnitTest ' )->will ($ this ->returnValue (true ));
800
- $ this ->Task ->expects ($ this ->once ())->method ('getAllTables ' )->will ($ this ->returnValue (array ('articles ' , 'bake_odd ' )));
801
- $ object = new Model (array ('name ' => 'BakeOdd ' , 'table ' => 'bake_odd ' , 'ds ' => 'test ' ));
802
- $ this ->Task ->expects ($ this ->once ())->method ('_getModelObject ' )->with ('BakeOdd ' , 'bake_odd ' )->will ($ this ->returnValue ($ object ));
803
- $ this ->Task ->expects ($ this ->once ())->method ('bake ' )->with ($ object , false )->will ($ this ->returnValue (true ));
804
- $ this ->Task ->expects ($ this ->once ())->method ('bakeFixture ' )->with ('BakeOdd ' , 'bake_odd ' );
712
+ $ filename = '/my/path/Entity/BakeComment.php ' ;
713
+ $ this ->Task ->expects ($ this ->at (5 ))
714
+ ->method ('createFile ' )
715
+ ->with ($ filename , $ this ->stringContains ('class BakeComment extends ' ));
805
716
806
- $ this ->Task ->execute ();
717
+ $ filename = '/my/path/Table/BakeTagsTable.php ' ;
718
+ $ this ->Task ->expects ($ this ->at (6 ))
719
+ ->method ('createFile ' )
720
+ ->with ($ filename , $ this ->stringContains ('class BakeTagsTable extends ' ));
807
721
808
- $ out = $ this ->getMock ('ConsoleOutput ' , array (), array (), '' , false );
809
- $ in = $ this ->getMock ('ConsoleInput ' , array (), array (), '' , false );
810
- $ this ->Task = $ this ->getMock ('ModelTask ' ,
811
- array ('in ' , 'err ' , '_stop ' , '_checkUnitTest ' , 'getAllTables ' , '_getModelObject ' , 'doAssociations ' , 'doValidation ' , 'doActsAs ' , 'createFile ' ),
812
- array ($ out , $ out , $ in )
813
- );
814
- $ this ->_setupOtherMocks ();
722
+ $ filename = '/my/path/Entity/BakeTag.php ' ;
723
+ $ this ->Task ->expects ($ this ->at (7 ))
724
+ ->method ('createFile ' )
725
+ ->with ($ filename , $ this ->stringContains ('class BakeTag extends ' ));
815
726
816
- $ this ->Task ->connection = 'test ' ;
817
- $ this ->Task ->path = '/my/path/ ' ;
818
- $ this ->Task ->args = array ('BakeOdd ' );
819
- $ this ->Task ->expects ($ this ->once ())->method ('_checkUnitTest ' )->will ($ this ->returnValue (true ));
820
- $ this ->Task ->expects ($ this ->once ())->method ('getAllTables ' )->will ($ this ->returnValue (array ('articles ' , 'bake_odd ' )));
821
- $ object = new Model (array ('name ' => 'BakeOdd ' , 'table ' => 'bake_odd ' , 'ds ' => 'test ' ));
822
- $ this ->Task ->expects ($ this ->once ())->method ('_getModelObject ' )->will ($ this ->returnValue ($ object ));
823
- $ this ->Task ->expects ($ this ->once ())->method ('doAssociations ' )->will ($ this ->returnValue (array ()));
824
- $ this ->Task ->expects ($ this ->once ())->method ('doValidation ' )->will ($ this ->returnValue (array ()));
825
- $ this ->Task ->expects ($ this ->once ())->method ('doActsAs ' )->will ($ this ->returnValue (array ()));
826
-
827
- $ filename = '/my/path/BakeOdd.php ' ;
828
- $ this ->Task ->expects ($ this ->once ())->method ('createFile ' )
829
- ->with ($ filename , $ this ->stringContains ('class BakeOdd ' ));
727
+ $ filename = '/my/path/Table/CategoryThreadsTable.php ' ;
728
+ $ this ->Task ->expects ($ this ->at (8 ))
729
+ ->method ('createFile ' )
730
+ ->with ($ filename , $ this ->stringContains ('class CategoryThreadsTable extends ' ));
830
731
831
- $ filename = '/my/path/BakeOdd.php ' ;
832
- $ this ->Task ->expects ($ this ->once ())->method ('createFile ' )
833
- ->with ($ filename , $ this ->stringContains ('public $useTable = \'bake_odd \'' ));
732
+ $ filename = '/my/path/Entity/CategoryThread.php ' ;
733
+ $ this ->Task ->expects ($ this ->at (9 ))
734
+ ->method ('createFile ' )
735
+ ->with ($ filename , $ this ->stringContains ('class CategoryThread extends ' ));
834
736
835
737
$ this ->Task ->execute ();
836
738
}
@@ -841,58 +743,45 @@ public function testExecuteIntoBakeOddTables() {
841
743
* @return void
842
744
*/
843
745
public function testSkipTablesAndAll () {
844
- $ this ->markTestIncomplete ('Not done here yet ' );
845
746
$ count = count ($ this ->Task ->listAll ('test ' ));
846
747
if ($ count != count ($ this ->fixtures )) {
847
748
$ this ->markTestSkipped ('Additional tables detected. ' );
848
749
}
849
750
850
751
$ this ->Task ->connection = 'test ' ;
851
752
$ this ->Task ->path = '/my/path/ ' ;
852
- $ this ->Task ->args = array ('all ' );
853
- $ this ->Task ->expects ($ this ->once ())->method ('_checkUnitTest ' )->will ($ this ->returnValue (true ));
854
- $ this ->Task ->skipTables = array ('bake_tags ' );
855
-
856
- $ this ->Task ->Fixture ->expects ($ this ->exactly (4 ))->method ('bake ' );
857
- $ this ->Task ->Test ->expects ($ this ->exactly (4 ))->method ('bake ' );
753
+ $ this ->Task ->args = ['all ' ];
754
+ $ this ->Task ->skipTables = ['bake_tags ' ];
858
755
859
- $ filename = '/my/path/BakeArticle.php ' ;
860
- $ this ->Task ->expects ($ this ->at (1 ))->method ('createFile ' )
861
- ->with ($ filename , $ this ->stringContains ('class BakeArticle ' ));
862
-
863
- $ filename = '/my/path/BakeArticlesBakeTag.php ' ;
864
- $ this ->Task ->expects ($ this ->at (2 ))->method ('createFile ' )
865
- ->with ($ filename , $ this ->stringContains ('class BakeArticlesBakeTag ' ));
756
+ $ this ->Task ->Fixture ->expects ($ this ->exactly (5 ))
757
+ ->method ('bake ' );
758
+ $ this ->Task ->Test ->expects ($ this ->exactly (5 ))
759
+ ->method ('bake ' );
866
760
867
- $ filename = '/my/path/BakeComment.php ' ;
868
- $ this ->Task ->expects ($ this ->at (3 ))->method ('createFile ' )
869
- ->with ($ filename , $ this ->stringContains ('class BakeComment ' ));
761
+ $ filename = '/my/path/Entity/BakeArticle.php ' ;
762
+ $ this ->Task ->expects ($ this ->at (1 ))
763
+ ->method ('createFile ' )
764
+ ->with ($ filename );
870
765
871
- $ filename = '/my/path/CategoryThread.php ' ;
872
- $ this ->Task ->expects ($ this ->at (4 ))->method ('createFile ' )
873
- ->with ($ filename , $ this ->stringContains ('class CategoryThread ' ));
766
+ $ filename = '/my/path/Entity/BakeArticlesBakeTag.php ' ;
767
+ $ this ->Task ->expects ($ this ->at (3 ))
768
+ ->method ('createFile ' )
769
+ ->with ($ filename );
874
770
875
- $ this ->Task ->execute ();
876
- }
771
+ $ filename = '/my/path/Entity/BakeComment.php ' ;
772
+ $ this ->Task ->expects ($ this ->at (5 ))
773
+ ->method ('createFile ' )
774
+ ->with ($ filename );
877
775
878
- /**
879
- * test using bake interactively with a table that does not exist.
880
- *
881
- * @return void
882
- */
883
- public function testForcedExecuteWithNonExistantTableName () {
884
- $ this ->markTestIncomplete ('Not done here yet ' );
885
- $ this ->Task ->connection = 'test ' ;
886
- $ this ->Task ->path = '/my/path/ ' ;
776
+ $ filename = '/my/path/Entity/CategoryThread.php ' ;
777
+ $ this ->Task ->expects ($ this ->at (7 ))
778
+ ->method ('createFile ' )
779
+ ->with ($ filename );
887
780
888
- $ this ->Task ->expects ($ this ->any ())->method ('in ' )
889
- ->will ($ this ->onConsecutiveCalls (
890
- 'Foobar ' , // Or type in the name of the model
891
- 'y ' , // Do you want to use this table
892
- 'y ' , // Doesn't exist, continue anyway?
893
- 'id ' , // Primary key
894
- 'y ' // Looks good?
895
- ));
781
+ $ filename = '/my/path/Entity/NumberTree.php ' ;
782
+ $ this ->Task ->expects ($ this ->at (9 ))
783
+ ->method ('createFile ' )
784
+ ->with ($ filename );
896
785
897
786
$ this ->Task ->execute ();
898
787
}
0 commit comments